summaryrefslogtreecommitdiff
path: root/hadrian/src/Packages.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Packages.hs')
-rw-r--r--hadrian/src/Packages.hs33
1 files changed, 26 insertions, 7 deletions
diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs
index 02dc134387..8d2aef1c7b 100644
--- a/hadrian/src/Packages.hs
+++ b/hadrian/src/Packages.hs
@@ -12,7 +12,8 @@ module Packages (
-- * Package information
programName, nonHsMainPackage, autogenPath, programPath, timeoutPath,
- rtsContext, rtsBuildPath, libffiContext, libffiBuildPath, libffiLibraryName
+ rtsContext, rtsBuildPath, libffiContext, libffiBuildPath, libffiLibraryName,
+ generatedGhcDependencies, ensureConfigured
) where
import Hadrian.Package
@@ -145,7 +146,7 @@ programName Context {..} = do
(Profiling, "-prof"),
(Dynamic, "-dyn")
]]
- _ -> pkgName package
+ _ -> pkgName package
-- | The 'FilePath' to a program executable in a given 'Context'.
programPath :: Context -> Action FilePath
@@ -170,8 +171,8 @@ timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe
nonHsMainPackage :: Package -> Bool
nonHsMainPackage = (`elem` [ghc, hp2ps, iserv, touchy, unlit])
--- TODO: Can we extract this information from Cabal files?
--- | Path to the @autogen@ directory generated when configuring a package.
+-- TODO: Combine this with 'programName'.
+-- | Path to the @autogen@ directory generated by 'buildAutogenFiles'.
autogenPath :: Context -> Action FilePath
autogenPath context@Context {..}
| isLibrary package = autogen "build"
@@ -181,6 +182,16 @@ autogenPath context@Context {..}
where
autogen dir = contextPath context <&> (-/- dir -/- "autogen")
+-- | Make sure a given context has already been fully configured. The
+-- implementation simply calls 'need' on the context's @autogen/cabal_macros.h@
+-- file, which triggers 'configurePackage' and 'buildAutogenFiles'. Why this
+-- indirection? Going via @autogen/cabal_macros.h@ allows us to cache the
+-- configuration steps, i.e. not to repeat them if they have already been done.
+ensureConfigured :: Context -> Action ()
+ensureConfigured context = do
+ autogen <- autogenPath context
+ need [autogen -/- "cabal_macros.h"]
+
-- | RTS is considered a Stage1 package. This determines RTS build directory.
rtsContext :: Stage -> Context
rtsContext stage = vanillaContext stage rts
@@ -189,9 +200,8 @@ rtsContext stage = vanillaContext stage rts
rtsBuildPath :: Stage -> Action FilePath
rtsBuildPath stage = buildPath (rtsContext stage)
--- | Build directory for libffi
--- This probably doesn't need to be stage dependent but it is for
--- consistency for now.
+-- | Build directory for @libffi@. This probably doesn't need to be stage
+-- dependent but it is for consistency for now.
libffiContext :: Stage -> Context
libffiContext stage = vanillaContext stage libffi
@@ -208,3 +218,12 @@ libffiLibraryName = do
(True , False) -> "ffi"
(False, False) -> "Cffi"
(_ , True ) -> "Cffi-6"
+
+-- | Generated header files required by GHC in runtime.
+generatedGhcDependencies :: Stage -> Action [FilePath]
+generatedGhcDependencies stage = do
+ let context = vanillaContext stage compiler
+ bh <- buildPath context <&> (-/- "ghc_boot_platform.h")
+ ch <- contextPath context <&> (-/- "ghc_boot_platform.h")
+ is <- includesDependencies
+ return $ is ++ [bh, ch]