Add haddock build targets.
[hadrian.git] / src / Rules.hs
1 module Rules (
2 oracleRules, cabalRules, configRules, packageRules, generateTargets
3 ) where
4
5 import Way
6 import Base
7 import Util
8 import Stage
9 import Expression
10 import Oracles.PackageData
11 import Rules.Cabal
12 import Rules.Config
13 import Rules.Package
14 import Rules.Oracles
15 import Rules.Resources
16 import Settings.Ways
17 import Settings.User
18 import Settings.Util
19 import Settings.Packages
20 import Settings.TargetDirectory
21
22 -- generateTargets needs package-data.mk files of all target packages
23 generateTargets :: Rules ()
24 generateTargets = action $ do
25 targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
26 pkgs <- interpret (stageTarget stage) getPackages
27 fmap concat . forM pkgs $ \pkg -> do
28 let target = stagePackageTarget stage pkg
29 buildPath = targetPath stage pkg -/- "build"
30 buildGhciLib <- interpret target $ getPkgData BuildGhciLib
31 pkgKey <- interpret target $ getPkgData PackageKey
32 buildHaddock <- interpret target $ Settings.User.buildHaddock
33 let ghciLib = [ buildPath -/- "HS" ++ pkgKey <.> "o"
34 | buildGhciLib == "YES" && stage /= Stage0 ]
35 haddock = [ pkgHaddockPath pkg | buildHaddock ]
36
37 ways <- interpret target getWays
38 libs <- forM ways $ \way -> do
39 extension <- libsuf way
40 return $ buildPath -/- "libHS" ++ pkgKey <.> extension
41
42 return $ ghciLib ++ libs ++ haddock
43
44 need $ reverse targets
45
46 -- TODO: add Stage2 (compiler only?)
47 packageRules :: Rules ()
48 packageRules = do
49 resources <- resourceRules
50 forM_ [Stage0, Stage1] $ \stage -> do
51 forM_ knownPackages $ \pkg -> do
52 buildPackage resources (stagePackageTarget stage pkg)