[commit: ghc] wip/nfs-locking: Factor out build :: Target -> Action () into Rules/Util.hs. (5db0017)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:12:36 UTC 2017


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

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

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

commit 5db0017b40d59894d5a6d4d5ba22196f55c47a48
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Tue Jul 14 11:39:23 2015 +0100

    Factor out build :: Target -> Action () into Rules/Util.hs.


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

5db0017b40d59894d5a6d4d5ba22196f55c47a48
 src/Rules/Data.hs | 21 +++++----------------
 src/Rules/Util.hs | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/Rules/Data.hs b/src/Rules/Data.hs
index dabccc1..f3c6064 100644
--- a/src/Rules/Data.hs
+++ b/src/Rules/Data.hs
@@ -9,11 +9,10 @@ import Package
 import Expression hiding (when, liftIO)
 import Oracles.Flag (when)
 import Oracles.Builder
-import Oracles.ArgsHash
-import Settings
 import Settings.GhcPkg
 import Settings.GhcCabal
 import Settings.TargetDirectory
+import Rules.Util
 import Util
 import Ways
 
@@ -35,27 +34,17 @@ buildPackageData target =
     ] &%> \_ -> do
         let configure = pkgPath pkg </> "configure"
             -- TODO: 1) how to automate this? 2) handle multiple files?
-            newTarget = target { getFile = path </> "package-data.mk" }
+            newTarget = target { getFile = path </> "package-data.mk"
+                               , getWay = vanilla } -- TODO: think
         -- GhcCabal will run the configure script, so we depend on it
         need [pkgPath pkg </> pkgCabal pkg]
         -- We still don't know who built the configure script from configure.ac
         when (doesFileExist $ configure <.> "ac") $ need [configure]
-        run' newTarget GhcCabal
+        build $ newTarget { getBuilder = GhcCabal }
         -- TODO: when (registerPackage settings) $
-        run' newTarget (GhcPkg stage)
+        build $ newTarget { getBuilder = GhcPkg stage }
         postProcessPackageData $ path </> "package-data.mk"
 
--- TODO: This should probably go to Oracles.Builder
-run' :: Target -> Builder -> Action ()
-run' target builder = do
-    let finalTarget = target {getBuilder = builder, getWay = vanilla }
-    args <- interpret finalTarget settings
-    putColoured Green (show args)
-    -- The line below forces the rule to be rerun if the hash has changed
-    argsHash <- askArgsHash finalTarget
-    putColoured Yellow (show argsHash)
-    run builder args
-
 -- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
 -- 1) Drop lines containing '$'
 -- For example, get rid of
diff --git a/src/Rules/Util.hs b/src/Rules/Util.hs
new file mode 100644
index 0000000..8c9f1c4
--- /dev/null
+++ b/src/Rules/Util.hs
@@ -0,0 +1,19 @@
+module Rules.Util (
+    build
+    ) where
+
+import Base
+import Util
+import Settings
+import Expression
+import Oracles.Builder
+import Oracles.ArgsHash
+
+build :: Target -> Action ()
+build target = do
+    args <- interpret target settings
+    putColoured Green (show target)
+    putColoured Green (show args)
+    -- The line below forces the rule to be rerun if the args hash has changed
+    argsHash <- askArgsHash target
+    run (getBuilder target) args



More information about the ghc-commits mailing list