[commit: ghc] wip/nfs-locking: Make generatedDependencies an Expr [FilePath] (234b41b)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:20:34 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/234b41b171ad31ecbfec476f8f47202cac6f10cc/ghc

>---------------------------------------------------------------

commit 234b41b171ad31ecbfec476f8f47202cac6f10cc
Author: Michal Terepeta <michal.terepeta at gmail.com>
Date:   Sun Jul 24 16:37:11 2016 +0200

    Make generatedDependencies an Expr [FilePath]
    
    This fixes a TODO to change the `generatedDependencies` to
    use `Expr`.
    
    Signed-off-by: Michal Terepeta <michal.terepeta at gmail.com>


>---------------------------------------------------------------

234b41b171ad31ecbfec476f8f47202cac6f10cc
 src/Rules/Data.hs     | 12 ++++----
 src/Rules/Generate.hs | 79 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/src/Rules/Data.hs b/src/Rules/Data.hs
index 959a7ec..4208570 100644
--- a/src/Rules/Data.hs
+++ b/src/Rules/Data.hs
@@ -25,7 +25,7 @@ buildPackageData context at 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 at 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 at 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 at 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 at 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 at 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" ]
diff --git a/src/Rules/Generate.hs b/src/Rules/Generate.hs
index 17f51a5..415692b 100644
--- a/src/Rules/Generate.hs
+++ b/src/Rules/Generate.hs
@@ -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



More information about the ghc-commits mailing list