43538755c62e2277f756ff1be7f603762a1adaf5
[hadrian.git] / src / Settings / Builders / DeriveConstants.hs
1 module Settings.Builders.DeriveConstants (
2 derivedConstantsPath, deriveConstantsArgs
3 ) where
4
5 import Expression
6 import Oracles.Config.Flag
7 import Oracles.Config.Setting
8 import Predicates (builder, file)
9 import Settings.Builders.GhcCabal
10
11 derivedConstantsPath :: FilePath
12 derivedConstantsPath = "includes/dist-derivedconstants/header"
13
14 -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
15 deriveConstantsArgs :: Args
16 deriveConstantsArgs = builder DeriveConstants ? do
17 cFlags <- fromDiffExpr includeCcArgs
18 mconcat
19 [ file "//DerivedConstants.h" ? arg "--gen-header"
20 , file "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
21 , file "//platformConstants" ? arg "--gen-haskell-value"
22 , file "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
23 , file "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
24 , arg "-o", arg =<< getOutput
25 , arg "--tmpdir", arg derivedConstantsPath
26 , arg "--gcc-program", arg =<< getBuilderPath (Gcc Stage1)
27 , append . concat $ map (\a -> ["--gcc-flag", a]) cFlags
28 , arg "--nm-program", arg =<< getBuilderPath Nm
29 , specified Objdump ? mconcat [ arg "--objdump-program"
30 , arg =<< getBuilderPath Objdump ]
31 , arg "--target-os", arg =<< getSetting TargetOs ]
32
33 includeCcArgs :: Args
34 includeCcArgs = do
35 confCcArgs <- lift . settingList $ ConfCcArgs Stage1
36 mconcat
37 [ ccArgs
38 , ccWarnings
39 , append confCcArgs
40 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
41 , append $ map ("-I" ++) ghcIncludeDirs -- TODO: fix code duplication
42 , arg "-Irts"
43 , notM ghcWithSMP ? arg "-DNOSMP"
44 , arg "-fcommon" ]