Add buildProgram rule.
[hadrian.git] / src / Rules / Program.hs
1 module Rules.Program (buildProgram) where
2
3 import Expression hiding (splitPath)
4 import Oracles
5 import Rules.Actions
6 import Rules.Library
7 import Rules.Resources
8 import Settings
9
10 buildProgram :: Resources -> PartialTarget -> Rules ()
11 buildProgram _ target @ (PartialTarget stage pkg) = do
12 let path = targetPath stage pkg
13 buildPath = path -/- "build"
14 program = programPath stage pkg
15
16 (\f -> program == Just f) ?> \bin -> do
17 cSrcs <- cSources target -- TODO: remove code duplication (Library.hs)
18 hSrcs <- hSources target
19 let cObjs = [ buildPath -/- src -<.> osuf vanilla | src <- cSrcs ]
20 hObjs = [ buildPath -/- src <.> osuf vanilla | src <- hSrcs ]
21 objs = cObjs ++ hObjs
22 need objs
23 build $ fullTargetWithWay target (Ghc stage) vanilla objs [bin]
24 synopsis <- interpretPartial target $ getPkgData Synopsis
25 putSuccess $ "/--------\n| Successfully built program '"
26 ++ pkgName pkg ++ "' (stage " ++ show stage ++ ")."
27 putSuccess $ "| Executable: " ++ bin
28 putSuccess $ "| Package synopsis: "
29 ++ dropWhileEnd isPunctuation synopsis ++ "." ++ "\n\\--------"