6b81a47579f392b4c231509040536d80eff551ed
[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 pkg) = do
11 let path = targetPath stage pkg
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 -- TODO: add dependencies for #include of .h and .hs-incl files (gcc -MM?)
21 matchBuildResult buildPath "o" ?> \obj -> do
22 (src, deps) <- dependencies buildPath obj
23 need $ src : deps
24 if ("//*.c" ?== src)
25 then build $ fullTarget target (Gcc stage) [src] [obj]
26 else do
27 let way = detectWay obj
28 build $ fullTargetWithWay target (Ghc stage) way [src] [obj]
29
30 -- TODO: get rid of these special cases
31 matchBuildResult buildPath "o-boot" ?> \obj -> do
32 (src, deps) <- dependencies buildPath obj
33 need $ src : deps
34 let way = detectWay obj
35 build $ fullTargetWithWay target (Ghc stage) way [src] [obj]