a17d9355f8d5c5e56582a5d5a2ab1891427790da
[hadrian.git] / src / Settings / Builders / DeriveConstants.hs
1 module Settings.Builders.DeriveConstants (deriveConstantsBuilderArgs) where
2
3 import Base
4 import Oracles.Config.Flag
5 import Oracles.Config.Setting
6 import Predicate
7 import Settings.Builders.Common
8
9 -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
10 deriveConstantsBuilderArgs :: Args
11 deriveConstantsBuilderArgs = builder DeriveConstants ? do
12 cFlags <- fromDiffExpr includeCcArgs
13 [outputFile, tempDir] <- getOutputs
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 Compile Stage1)
23 , append . concat $ map (\a -> ["--gcc-flag", a]) cFlags
24 , arg "--nm-program", arg =<< getBuilderPath Nm
25 , specified Objdump ? mconcat [ arg "--objdump-program"
26 , arg =<< getBuilderPath Objdump ]
27 , arg "--target-os", argSetting TargetOs ]
28
29 includeCcArgs :: Args
30 includeCcArgs = do
31 confCcArgs <- getSettingList $ ConfCcArgs Stage1
32 mconcat
33 [ cArgs
34 , cWarnings
35 , append confCcArgs
36 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
37 , includesArgs
38 , arg "-Irts"
39 , notM ghcWithSMP ? arg "-DNOSMP"
40 , arg "-fcommon" ]