Refactor builder path manipulation
[hadrian.git] / src / Settings / Builders / DeriveConstants.hs
1 module Settings.Builders.DeriveConstants (deriveConstantsBuilderArgs) where
2
3 import Settings.Builders.Common
4
5 -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
6 deriveConstantsBuilderArgs :: Args
7 deriveConstantsBuilderArgs = builder DeriveConstants ? do
8 cFlags <- fromDiffExpr includeCcArgs
9 [outputFile, tempDir] <- getOutputs
10 mconcat
11 [ output "//DerivedConstants.h" ? arg "--gen-header"
12 , output "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
13 , output "//platformConstants" ? arg "--gen-haskell-value"
14 , output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
15 , output "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
16 , arg "-o", arg outputFile
17 , arg "--tmpdir", arg tempDir
18 , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
19 , append $ concatMap (\a -> ["--gcc-flag", a]) cFlags
20 , arg "--nm-program", arg =<< getBuilderPath Nm
21 , isSpecified Objdump ? mconcat [ arg "--objdump-program"
22 , arg =<< getBuilderPath Objdump ]
23 , arg "--target-os", argSetting TargetOs ]
24
25 includeCcArgs :: Args
26 includeCcArgs = mconcat
27 [ cArgs
28 , cWarnings
29 , argSettingList $ ConfCcArgs Stage1
30 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
31 , arg "-Irts"
32 , arg "-Iincludes"
33 , arg $ "-I" ++ generatedPath
34 , notM ghcWithSMP ? arg "-DNOSMP"
35 , arg "-fcommon" ]