[commit: ghc] wip/nfs-locking: Factor out build rules into Rules.buildRules. (e7f8710)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:49:44 UTC 2017


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

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

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

commit e7f8710c591d5329e4a06df538ca0aa789b065a0
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Feb 14 22:59:11 2016 +0000

    Factor out build rules into Rules.buildRules.


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

e7f8710c591d5329e4a06df538ca0aa789b065a0
 src/Main.hs  | 17 ++---------------
 src/Rules.hs | 39 ++++++++++++++++++++++++++++-----------
 2 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/src/Main.hs b/src/Main.hs
index 544987d..e028597 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -6,14 +6,8 @@ import qualified Base
 import qualified CmdLineFlag
 import qualified Environment
 import qualified Rules
-import qualified Rules.Cabal
 import qualified Rules.Clean
-import qualified Rules.Generate
-import qualified Rules.Gmp
-import qualified Rules.Libffi
 import qualified Rules.Oracles
-import qualified Rules.Perl
-import qualified Rules.Setup
 import qualified Selftest
 import qualified Test
 
@@ -27,17 +21,10 @@ main = shakeArgsWith options CmdLineFlag.cmdFlags $ \cmdLineFlags targets -> do
   where
     rules :: Rules ()
     rules = mconcat
-        [ Rules.Cabal.cabalRules
-        , Rules.Clean.cleanRules
-        , Rules.Generate.generateRules
-        , Rules.Generate.copyRules
-        , Rules.Gmp.gmpRules
-        , Rules.Libffi.libffiRules
+        [ Rules.Clean.cleanRules
         , Rules.Oracles.oracleRules
-        , Rules.Perl.perlScriptRules
-        , Rules.Setup.setupRules
+        , Rules.buildRules
         , Rules.topLevelTargets
-        , Rules.packageRules
         , Selftest.selftestRules
         , Test.testRules ]
     options = shakeOptions
diff --git a/src/Rules.hs b/src/Rules.hs
index 34cea4c..5cbfa7e 100644
--- a/src/Rules.hs
+++ b/src/Rules.hs
@@ -1,12 +1,18 @@
-module Rules (topLevelTargets, packageRules) where
+module Rules (topLevelTargets, buildRules) where
 
-import Base
 import Data.Foldable
+
+import Base
 import Expression
-import GHC hiding (haddock)
+import GHC
 import qualified Rules.Generate
-import Rules.Package
-import Rules.Resources
+import qualified Rules.Package
+import qualified Rules.Resources
+import qualified Rules.Cabal
+import qualified Rules.Gmp
+import qualified Rules.Libffi
+import qualified Rules.Perl
+import qualified Rules.Setup
 import Settings
 
 allStages :: [Stage]
@@ -32,16 +38,27 @@ topLevelTargets = do
             when (pkg `elem` activePackages) $
                 if isLibrary pkg
                 then do -- build a library
-                    ways    <- interpretInContext context getLibraryWays
-                    libs    <- traverse (pkgLibraryFile stage pkg) ways
-                    haddock <- interpretInContext context buildHaddock
-                    need $ libs ++ [ pkgHaddockFile pkg | haddock && stage == Stage1 ]
+                    ways <- interpretInContext context getLibraryWays
+                    libs <- traverse (pkgLibraryFile stage pkg) ways
+                    docs <- interpretInContext context buildHaddock
+                    need $ libs ++ [ pkgHaddockFile pkg | docs && stage == Stage1 ]
                 else do -- otherwise build a program
                     need [ fromJust $ programPath stage pkg ] -- TODO: drop fromJust
 
 packageRules :: Rules ()
 packageRules = do
-    resources <- resourceRules
+    resources <- Rules.Resources.resourceRules
     for_ allStages $ \stage ->
         for_ knownPackages $ \pkg ->
-            buildPackage resources $ vanillaContext stage pkg
+            Rules.Package.buildPackage resources $ vanillaContext stage pkg
+
+buildRules :: Rules ()
+buildRules = mconcat
+    [ Rules.Cabal.cabalRules
+    , Rules.Generate.generateRules
+    , Rules.Generate.copyRules
+    , Rules.Gmp.gmpRules
+    , Rules.Libffi.libffiRules
+    , Rules.Perl.perlScriptRules
+    , Rules.Setup.setupRules
+    , Rules.packageRules ]



More information about the ghc-commits mailing list