Use Cabal directly in place of ghc-cabal + make build root configurable (#531)
[hadrian.git] / src / Rules / PackageData.hs
1 module Rules.PackageData (buildPackageData) where
2
3 import Base
4 import Context
5 import Expression
6 import GHC.Packages
7 import Settings.Packages.Rts
8 import Target
9 import Utilities
10
11 import Hadrian.Haskell.Cabal.Parse (configurePackage)
12
13 -- | Build @setup-config@ and @inplace-pkg-config@ files
14 -- for packages. Look at the "Rules" module to see this
15 -- instantiated against all the packages.
16 buildPackageData :: Context -> Rules ()
17 buildPackageData context@Context {..} = do
18 root <- buildRootRules
19 let dir = root -/- contextDir context
20 dir -/- "setup-config" %> \_ -> configurePackage context
21
22 dir -/- "inplace-pkg-config" %> \conf -> do
23 when (package == rts) $ do
24 genPath <- buildRoot <&> (-/- generatedDir)
25 rtsPath <- rtsBuildPath
26 need [rtsConfIn]
27 build $ target context HsCpp [rtsConfIn] [conf]
28 fixFile conf $ unlines
29 . map
30 ( replace "\"\"" ""
31 . replace "rts/dist/build" rtsPath
32 . replace "includes/dist-derivedconstants/header" genPath )
33 . lines