656e85339f72cd81392fe150fce70b1ed31744a0
[hadrian.git] / src / Rules / Dependencies.hs
1 module Rules.Dependencies (buildPackageDependencies) where
2
3 import Util
4 import Builder
5 import Package
6 import Expression
7 import qualified Target
8 import Oracles.PackageData
9 import Settings.Util
10 import Settings.TargetDirectory
11 import Rules.Actions
12 import Development.Shake
13
14 buildPackageDependencies :: StagePackageTarget -> Rules ()
15 buildPackageDependencies target =
16 let stage = Target.stage target
17 pkg = Target.package target
18 path = targetPath stage pkg
19 buildPath = path -/- "build"
20 dropBuild = (pkgPath pkg ++) . drop (length buildPath)
21 in do
22 (buildPath <//> "*.c.deps") %> \depFile -> do
23 let srcFile = dropBuild . dropExtension $ depFile
24 build $ fullTarget target [srcFile] (GccM stage) [depFile]
25
26 (buildPath -/- "c.deps") %> \file -> do
27 srcs <- pkgDataList $ CSrcs path
28 deps <- forM srcs $ \src -> readFile' $ buildPath -/- src <.> "deps"
29 writeFileChanged file (concat deps)
30
31 (buildPath -/- "haskell.deps") %> \file -> do
32 srcs <- interpretExpr target getHsSources
33 build $ fullTarget target srcs (GhcM stage) [file]