43f59225724cc34fdb02b10854246306e5a28acb
[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.Util
18 import Settings.Packages
19 import Settings.TargetDirectory
20
21 -- generateTargets needs package-data.mk files of all target packages
22 generateTargets :: Rules ()
23 generateTargets = action $ do
24 targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
25 pkgs <- interpret (stageTarget stage) getPackages
26 fmap concat . forM pkgs $ \pkg -> do
27 let target = stagePackageTarget stage pkg
28 buildPath = targetPath stage pkg -/- "build"
29 buildGhciLib <- interpret target $ getPkgData BuildGhciLib
30 pkgKey <- interpret target $ getPkgData PackageKey
31 let ghciLib = [ buildPath -/- "HS" ++ pkgKey <.> "o"
32 | buildGhciLib == "YES" && stage /= Stage0 ]
33
34 ways <- interpret target getWays
35 libs <- forM ways $ \way -> do
36 extension <- libsuf way
37 return $ buildPath -/- "libHS" ++ pkgKey <.> extension
38
39 return $ ghciLib ++ libs
40
41 need $ reverse targets
42
43 -- TODO: add Stage2 (compiler only?)
44 packageRules :: Rules ()
45 packageRules = do
46 resources <- resourceRules
47 forM_ [Stage0, Stage1] $ \stage -> do
48 forM_ knownPackages $ \pkg -> do
49 buildPackage resources (stagePackageTarget stage pkg)