Make build badges more informative
[hadrian.git] / src / Rules.hs
1 module Rules (generateTargets, packageRules) where
2
3 import Base
4 import Data.Foldable
5 import Data.Traversable
6 import Expression
7 import GHC
8 import Rules.Generate
9 import Rules.Package
10 import Rules.Resources
11 import Settings
12
13 allStages :: [Stage]
14 allStages = [minBound ..]
15
16 -- TODO: not all program targets should be needed explicitly
17 -- | 'need' all top-level build targets
18 generateTargets :: Rules ()
19 generateTargets = action $ do
20 targets <- fmap concat (traverse targetsForStage allStages)
21 rtsLib <- pkgLibraryFile Stage1 rts "rts" vanilla
22 need $ targets ++ installTargets ++ [ rtsLib ]
23
24 targetsForStage :: Stage -> Action [String]
25 targetsForStage stage = do
26 pkgs <- interpretWithStage stage getPackages
27 let libPkgs = filter isLibrary pkgs \\ [rts, libffi]
28 libTargets <- fmap concat . for libPkgs $ \pkg -> do
29 let target = PartialTarget stage pkg
30 needHaddock <- interpretPartial target buildHaddock
31 return [ pkgHaddockFile pkg | needHaddock && stage == Stage1 ]
32 let programTargets = [ prog | Just prog <- programPath stage <$> pkgs ]
33 return (libTargets ++ programTargets)
34
35 packageRules :: Rules ()
36 packageRules = do
37 resources <- resourceRules
38 for_ allStages $ \stage ->
39 for_ knownPackages $ \pkg ->
40 buildPackage resources $ PartialTarget stage pkg