Use Cabal directly in place of ghc-cabal + make build root configurable (#531)
[hadrian.git] / src / Settings / Builders / DeriveConstants.hs
1 module Settings.Builders.DeriveConstants (deriveConstantsBuilderArgs) where
2
3 import Builder
4 import Settings.Builders.Common
5
6 -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
7 deriveConstantsBuilderArgs :: Args
8 deriveConstantsBuilderArgs = builder DeriveConstants ? do
9 cFlags <- includeCcArgs
10 outs <- getOutputs
11 let (outputFile, tempDir) = case outs of
12 [a, b] -> (a, b)
13 _ -> error $ "DeriveConstants: expected two outputs, got " ++ show outs
14 mconcat
15 [ output "//DerivedConstants.h" ? arg "--gen-header"
16 , output "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
17 , output "//platformConstants" ? arg "--gen-haskell-value"
18 , output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
19 , output "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
20 , arg "-o", arg outputFile
21 , arg "--tmpdir", arg tempDir
22 , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
23 , pure $ concatMap (\a -> ["--gcc-flag", a]) cFlags
24 , arg "--nm-program", arg =<< getBuilderPath Nm
25 , isSpecified Objdump ? mconcat [ arg "--objdump-program"
26 , arg =<< getBuilderPath Objdump ]
27 , arg "--target-os", arg =<< getSetting TargetOs ]
28
29 includeCcArgs :: Args
30 includeCcArgs = do
31 root <- getBuildRoot
32 mconcat [ cArgs
33 , cWarnings
34 , getSettingList $ ConfCcArgs Stage1
35 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
36 , arg "-Irts"
37 , arg "-Iincludes"
38 , arg $ "-I" ++ root -/- generatedDir
39 , notM ghcWithSMP ? arg "-DNOSMP"
40 , arg "-fcommon" ]