[commit: ghc] wip/nfs-locking: Split compile rules for {hi, o}, clean up code. (3344cea)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:08:20 UTC 2017


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

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

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

commit 3344ceadaa807de7708c9444b1a71537fa0a7fdd
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Jan 18 13:34:58 2015 +0000

    Split compile rules for {hi, o}, clean up code.


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

3344ceadaa807de7708c9444b1a71537fa0a7fdd
 src/Oracles.hs         | 12 +++++++-----
 src/Package/Compile.hs | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/Oracles.hs b/src/Oracles.hs
index 4c6d9e9..215ccb7 100644
--- a/src/Oracles.hs
+++ b/src/Oracles.hs
@@ -67,15 +67,17 @@ packageDataOracle = do
 -- Oracle for 'path/dist/*.deps' files
 dependencyOracle :: Rules ()
 dependencyOracle = do
-    deps <- newCache $ \depFile -> do
-        need [depFile]
-        putOracle $ "Parsing " ++ toStandard depFile ++ "..."
-        contents <- parseMakefile <$> (liftIO $ readFile depFile)
+    deps <- newCache $ \file -> do
+        need [file]
+        putOracle $ "Parsing " ++ file ++ "..."
+        contents <- parseMakefile <$> (liftIO $ readFile file)
         return $ M.fromList
+               $ map (bimap toStandard (map toStandard))
                $ map (bimap head concat . unzip)
                $ groupBy ((==) `on` fst)
                $ sortBy (compare `on` fst) contents
-    addOracle $ \(DependencyListKey (file, obj)) -> M.lookup obj <$> deps file
+    addOracle $ \(DependencyListKey (file, obj)) ->
+        M.lookup (toStandard obj) <$> deps (toStandard file)
     return ()
 
 oracleRules :: Rules ()
diff --git a/src/Package/Compile.hs b/src/Package/Compile.hs
index e0080f9..762f533 100644
--- a/src/Package/Compile.hs
+++ b/src/Package/Compile.hs
@@ -47,10 +47,14 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
     forM_ allWays $ \way -> do -- TODO: optimise (too many ways in allWays)
         let oPattern  = "*." ++ osuf way
         let hiPattern = "*." ++ hisuf way
-        [buildDir <//> oPattern, buildDir <//> hiPattern] |%> \out -> do
+
+        (buildDir <//> hiPattern) %> \out -> do
+            let obj = out -<.> osuf way
+            need [obj]
+
+        (buildDir <//> oPattern) %> \obj -> do
             need [argListPath argListDir pkg stage]
-            let obj = toStandard $ out -<.> osuf way
-                vanillaObj = toStandard $ out -<.> "o"
+            let vanillaObj = obj -<.> "o"
             -- TODO: keep only vanilla dependencies in hDepFile
             hDeps <- args $ DependencyList hDepFile obj
             cDeps <- args $ DependencyList cDepFile $ takeFileName vanillaObj
@@ -59,10 +63,10 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
             -- Report impossible cases
             when (null $ hSrcs ++ cSrcs)
                 $ redError_ $ "No source files found for "
-                ++ toStandard out ++ "."
+                ++ toStandard obj ++ "."
             when (not (null hSrcs) && not (null cSrcs))
                 $ redError_ $ "Both c and Haskell sources found for "
-                ++ toStandard out ++ "."
+                ++ toStandard obj ++ "."
             -- Build using appropriate compiler
             need $ hDeps ++ cDeps
             when (not $ null hSrcs)
@@ -70,6 +74,7 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
             when (not $ null cSrcs)
                 $ run (Gcc stage) $ gccArgs pkg todo cSrcs obj
 
+
 argListRule :: Package -> TodoItem -> Rules ()
 argListRule pkg todo @ (stage, _, settings) =
     (argListPath argListDir pkg stage) %> \out -> do



More information about the ghc-commits mailing list