Commit 234b41b1 authored by Michal Terepeta's avatar Michal Terepeta
Browse files

Make generatedDependencies an Expr [FilePath]



This fixes a TODO to change the `generatedDependencies` to
use `Expr`.
Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
parent eff3e366
......@@ -25,7 +25,7 @@ buildPackageData context@Context {..} = do
inTreeMk %> \mk -> do
-- Make sure all generated dependencies are in place before proceeding.
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
-- GhcCabal may run the configure script, so we depend on it.
whenM (doesFileExist $ configure <.> "ac") $ need [configure]
......@@ -59,7 +59,7 @@ buildPackageData context@Context {..} = do
-- TODO: PROGNAME was $(CrossCompilePrefix)hp2ps.
priority 2.0 $ do
when (package == hp2ps) $ dataFile %> \mk -> do
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
includes <- interpretInContext context $ fromDiffExpr includesArgs
let prefix = fixKey (buildPath context) ++ "_"
cSrcs = [ "AreaBelow.c", "Curves.c", "Error.c", "Main.c"
......@@ -76,7 +76,7 @@ buildPackageData context@Context {..} = do
putSuccess $ "| Successfully generated " ++ mk
when (package == unlit) $ dataFile %> \mk -> do
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
let prefix = fixKey (buildPath context) ++ "_"
contents = unlines $ map (prefix++)
[ "PROGNAME = unlit"
......@@ -86,7 +86,7 @@ buildPackageData context@Context {..} = do
putSuccess $ "| Successfully generated " ++ mk
when (package == touchy) $ dataFile %> \mk -> do
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
let prefix = fixKey (buildPath context) ++ "_"
contents = unlines $ map (prefix++)
[ "PROGNAME = touchy"
......@@ -98,7 +98,7 @@ buildPackageData context@Context {..} = do
-- package, we cannot generate the corresponding `package-data.mk` file
-- by running by running `ghcCabal`, because it has not yet been built.
when (package == ghcCabal && stage == Stage0) $ dataFile %> \mk -> do
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
let prefix = fixKey (buildPath context) ++ "_"
contents = unlines $ map (prefix++)
[ "PROGNAME = ghc-cabal"
......@@ -110,7 +110,7 @@ buildPackageData context@Context {..} = do
when (package == rts && stage == Stage1) $ do
dataFile %> \mk -> do
orderOnly $ generatedDependencies stage package
orderOnly =<< interpretInContext context generatedDependencies
windows <- windowsHost
let prefix = fixKey (buildPath context) ++ "_"
dirs = [ ".", "hooks", "sm", "eventlog", "linker" ]
......
......@@ -10,6 +10,8 @@ import Context
import Expression
import GHC
import Oracles.ModuleFiles
import Predicate ( (?) )
import qualified Predicate as Predicate
import Rules.Actions
import Rules.Generators.ConfigHs
import Rules.Generators.GhcAutoconfH
......@@ -46,10 +48,11 @@ includesDependencies = ("includes" -/-) <$>
, "ghcplatform.h"
, "ghcversion.h" ]
ghcPrimDependencies :: Stage -> [FilePath]
ghcPrimDependencies stage = (buildPath (vanillaContext stage ghcPrim) -/-) <$>
[ "autogen/GHC/Prim.hs"
, "GHC/PrimopWrappers.hs" ]
ghcPrimDependencies :: Expr [FilePath]
ghcPrimDependencies = getStage >>= \stage ->
let prependPath x = buildPath (vanillaContext stage ghcPrim) -/- x
in return $
fmap prependPath [ "autogen/GHC/Prim.hs" , "GHC/PrimopWrappers.hs" ]
derivedConstantsPath :: FilePath
derivedConstantsPath = "includes/dist-derivedconstants/header"
......@@ -61,39 +64,43 @@ derivedConstantsDependencies = installTargets ++ fmap (derivedConstantsPath -/-)
, "GHCConstantsHaskellType.hs"
, "GHCConstantsHaskellWrappers.hs" ]
compilerDependencies :: Stage -> [FilePath]
compilerDependencies stage =
[ platformH stage ]
++ includesDependencies
++ [ gmpLibraryH | stage > Stage0 ]
++ filter (const $ stage > Stage0) libffiDependencies
++ derivedConstantsDependencies
++ fmap (buildPath (vanillaContext stage compiler) -/-)
[ "primop-can-fail.hs-incl"
, "primop-code-size.hs-incl"
, "primop-commutable.hs-incl"
, "primop-data-decl.hs-incl"
, "primop-fixity.hs-incl"
, "primop-has-side-effects.hs-incl"
, "primop-list.hs-incl"
, "primop-out-of-line.hs-incl"
, "primop-primop-info.hs-incl"
, "primop-strictness.hs-incl"
, "primop-tag.hs-incl"
, "primop-vector-tycons.hs-incl"
, "primop-vector-tys-exports.hs-incl"
, "primop-vector-tys.hs-incl"
, "primop-vector-uniques.hs-incl" ]
-- TODO: Turn this into a FilePaths expression
generatedDependencies :: Stage -> Package -> [FilePath]
generatedDependencies stage pkg
| pkg == compiler = compilerDependencies stage
| pkg == ghcPrim = ghcPrimDependencies stage
| pkg == rts = libffiDependencies ++ includesDependencies
compilerDependencies :: Expr [FilePath]
compilerDependencies = getStage >>= \stage ->
let prependBuildPath x = buildPath (vanillaContext stage compiler) -/- x
in mconcat $
[ return $ (platformH stage)
: includesDependencies
++ derivedConstantsDependencies
| stage == Stage0 = includesDependencies
| otherwise = []
, Predicate.notStage0 ? return (gmpLibraryH : libffiDependencies)
, return $ fmap prependBuildPath
[ "primop-can-fail.hs-incl"
, "primop-code-size.hs-incl"
, "primop-commutable.hs-incl"
, "primop-data-decl.hs-incl"
, "primop-fixity.hs-incl"
, "primop-has-side-effects.hs-incl"
, "primop-list.hs-incl"
, "primop-out-of-line.hs-incl"
, "primop-primop-info.hs-incl"
, "primop-strictness.hs-incl"
, "primop-tag.hs-incl"
, "primop-vector-tycons.hs-incl"
, "primop-vector-tys-exports.hs-incl"
, "primop-vector-tys.hs-incl"
, "primop-vector-uniques.hs-incl"
]
]
generatedDependencies :: Expr [FilePath]
generatedDependencies = mconcat
[ Predicate.package compiler ? compilerDependencies
, Predicate.package ghcPrim ? ghcPrimDependencies
, Predicate.package rts ? return (
libffiDependencies
++ includesDependencies
++ derivedConstantsDependencies)
, Predicate.stage0 ? return includesDependencies
]
generate :: FilePath -> Context -> Expr String -> Action ()
generate file context expr = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment