Commit 20381e58 authored by quchen's avatar quchen
Browse files

Split up definitions in Rules.hs

parent de634dad
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment