diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-10-05 16:45:04 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-12-13 17:49:05 -0500 |
commit | 3f434e34e74bee03ba67b62dda9dd227b183d7d6 (patch) | |
tree | 103813443363735a3abfc3d59c10703bcf1d4f5a | |
parent | 401ddd5300c8be2ee03bf040146e7f2878bae0a9 (diff) | |
download | haskell-3f434e34e74bee03ba67b62dda9dd227b183d7d6.tar.gz |
Introduce `hs-pkg path` entry in --info outputwip/T18807
Previously build tools had no reliable means of determining the location
of `ghc-pkg`. Given that Cabal queries `ghc --info` already, this seems
like a reasonable place to place this information.
Fixes #18807.
-rw-r--r-- | hadrian/bindist/Makefile | 1 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 1 | ||||
-rw-r--r-- | rts/include/ghc.mk | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/T18807.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 1 |
5 files changed, 19 insertions, 0 deletions
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile index 3ae599452f..d6fcd226e8 100644 --- a/hadrian/bindist/Makefile +++ b/hadrian/bindist/Makefile @@ -125,6 +125,7 @@ lib/settings : @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ @echo ',("libtool command", "$(SettingsLibtoolCommand)")' >> $@ @echo ',("unlit command", "$$topdir/bin/unlit")' >> $@ + @echo ',("hc-pkg command", "$(ActualBinsDir)/bin/ghc-pkg")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 19ff80f6ea..6ac38c5521 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -307,6 +307,7 @@ generateSettings = do , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) , ("libtool command", expr $ settingsFileSetting SettingsFileSetting_LibtoolCommand) , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) + , ("hc-pkg path", expr ((</>) <$> topDirectory <*> programPath (ctx { Context.package = ghcPkg }))) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling) , ("target platform string", getSetting TargetPlatform) , ("target os", getSetting TargetOsHaskell) diff --git a/rts/include/ghc.mk b/rts/include/ghc.mk index cfedf62ea8..eeb6d22fe7 100644 --- a/rts/include/ghc.mk +++ b/rts/include/ghc.mk @@ -217,6 +217,7 @@ $(includes_SETTINGS) : rts/include/Makefile | $$(dir $$@)/. @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ @echo ',("libtool command", "$(SettingsLibtoolCommand)")' >> $@ @echo ',("unlit command", "$$topdir/bin/$(utils/unlit_dist_PROG)")' >> $@ + @echo ',("hc-pkg command", "$$topdir/bin/$(utils/ghc-pkg_dist_PROG)")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@ diff --git a/testsuite/tests/driver/T18807.hs b/testsuite/tests/driver/T18807.hs new file mode 100644 index 0000000000..4f9764e507 --- /dev/null +++ b/testsuite/tests/driver/T18807.hs @@ -0,0 +1,15 @@ +module Main where + +import System.Process +import System.Directory +import System.Environment + +main :: IO () +main = do + ghcPath <- getEnv "TEST_HC" + out <- readProcess ghcPath ["--info"] "" + let settings :: [(String, String)] + settings = read out + let Just hcPkgPath = lookup "hc-pkg path" settings + _versionOut <- readProcess hcPkgPath ["--version"] "" + return () diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 4af15b7640..af7f512ea8 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -288,6 +288,7 @@ test('T16737', test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code']) test('T17786', unless(opsys('mingw32'), skip), makefile_test, []) +test('T18807', normal, compile_and_run, ['']) test('T18369', normal, compile, ['-O']) test('FullGHCVersion', normal, compile_and_run, ['-package ghc-boot']) test('OneShotTH', normal, makefile_test, []) |