[commit: ghc] wip/nfs-locking: Split up definitions in Rules.hs (20381e5)
git at git.haskell.org
git at git.haskell.org
Fri Oct 27 00:31:02 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/20381e58208ca2693f034566e450f5b0b28674b4/ghc
>---------------------------------------------------------------
commit 20381e58208ca2693f034566e450f5b0b28674b4
Author: David Luposchainsky <dluposchainsky at gmail.com>
Date: Wed Jan 6 14:49:58 2016 +0100
Split up definitions in Rules.hs
>---------------------------------------------------------------
20381e58208ca2693f034566e450f5b0b28674b4
src/Rules.hs | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/Rules.hs b/src/Rules.hs
index 22c5230..f8b2810 100644
--- a/src/Rules.hs
+++ b/src/Rules.hs
@@ -1,6 +1,8 @@
module Rules (generateTargets, packageRules) where
import Base
+import Data.Foldable
+import Data.Traversable
import Expression
import GHC
import Rules.Generate
@@ -8,26 +10,31 @@ import Rules.Package
import Rules.Resources
import Settings
+allStages :: [Stage]
+allStages = [Stage0 ..]
+
-- TODO: not all program targets should be needed explicitly
--- | generateTargets needs top-level build targets
+-- | 'need' all top-level build targets
generateTargets :: Rules ()
generateTargets = action $ do
- targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
- pkgs <- interpretWithStage stage getPackages
- let libPkgs = filter isLibrary pkgs \\ [rts, libffi]
- libTargets <- fmap concat . forM libPkgs $ \pkg -> do
- let target = PartialTarget stage pkg
- needHaddock <- interpretPartial target buildHaddock
- return [ pkgHaddockFile pkg | needHaddock && stage == Stage1 ]
- let programTargets = [ prog | Just prog <- programPath stage <$> pkgs ]
- return $ libTargets ++ programTargets
-
+ targets <- fmap concat (traverse targetsForStage allStages)
rtsLib <- pkgLibraryFile Stage1 rts "rts" vanilla
need $ targets ++ installTargets ++ [ rtsLib ]
+targetsForStage :: Stage -> Action [String]
+targetsForStage stage = do
+ pkgs <- interpretWithStage stage getPackages
+ let libPkgs = filter isLibrary pkgs \\ [rts, libffi]
+ libTargets <- fmap concat . for libPkgs $ \pkg -> do
+ let target = PartialTarget stage pkg
+ needHaddock <- interpretPartial target buildHaddock
+ return [ pkgHaddockFile pkg | needHaddock && stage == Stage1 ]
+ let programTargets = [ prog | Just prog <- programPath stage <$> pkgs ]
+ return (libTargets ++ programTargets)
+
packageRules :: Rules ()
packageRules = do
resources <- resourceRules
- forM_ [Stage0 ..] $ \stage ->
- forM_ knownPackages $ \pkg ->
+ for allStages $ \stage ->
+ for_ knownPackages $ \pkg ->
buildPackage resources $ PartialTarget stage pkg
More information about the ghc-commits
mailing list