Add buildProgram rule.
[hadrian.git] / src / Rules / Compile.hs
1 module Rules.Compile (compilePackage) where
2
3 import Expression
4 import Oracles
5 import Rules.Actions
6 import Rules.Resources
7 import Settings
8
9 compilePackage :: Resources -> PartialTarget -> Rules ()
10 compilePackage _ target @ (PartialTarget stage package) = do
11 let path = targetPath stage package
12 buildPath = path -/- "build"
13
14 matchBuildResult buildPath "hi" ?> \hi ->
15 need [ hi -<.> osuf (detectWay hi) ]
16
17 matchBuildResult buildPath "hi-boot" ?> \hiboot ->
18 need [ hiboot -<.> obootsuf (detectWay hiboot) ]
19
20 matchBuildResult buildPath "o" ?> \obj -> do
21 (src, deps) <- dependencies buildPath obj
22 need $ src : deps
23 if ("//*.c" ?== src)
24 then build $ fullTarget target (Gcc stage) [src] [obj]
25 else do
26 let way = detectWay obj
27 build $ fullTargetWithWay target (Ghc stage) way [src] [obj]
28
29 matchBuildResult buildPath "o-boot" ?> \obj -> do
30 (src, deps) <- dependencies buildPath obj
31 need $ src : deps
32 let way = detectWay obj
33 build $ fullTargetWithWay target (Ghc stage) way [src] [obj]