Add Base.hs with Shake imports and build paths.
[hadrian.git] / src / Rules / Dependencies.hs
1 module Rules.Dependencies (buildPackageDependencies) where
2
3 import Base
4 import Util
5 import Builder
6 import Package
7 import Expression
8 import qualified Target
9 import Oracles.PackageData
10 import Settings.Util
11 import Settings.TargetDirectory
12 import Rules.Actions
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]