Squashed 'hadrian/' content from commit 438dc57
[ghc.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 <- includeCcArgs
9 outs <- getOutputs
10 let (outputFile, tempDir) = case outs of
11 [a, b] -> (a, b)
12 _ -> error $ "DeriveConstants: expected two outputs, got " ++ show outs
13 mconcat
14 [ output "//DerivedConstants.h" ? arg "--gen-header"
15 , output "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
16 , output "//platformConstants" ? arg "--gen-haskell-value"
17 , output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
18 , output "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
19 , arg "-o", arg outputFile
20 , arg "--tmpdir", arg tempDir
21 , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
22 , pure $ concatMap (\a -> ["--gcc-flag", a]) cFlags
23 , arg "--nm-program", arg =<< getBuilderPath Nm
24 , isSpecified Objdump ? mconcat [ arg "--objdump-program"
25 , arg =<< getBuilderPath Objdump ]
26 , arg "--target-os", arg =<< getSetting TargetOs ]
27
28 includeCcArgs :: Args
29 includeCcArgs = do
30 root <- getBuildRoot
31 mconcat [ cArgs
32 , cWarnings
33 , getSettingList $ ConfCcArgs Stage1
34 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
35 , arg "-Irts"
36 , arg "-Iincludes"
37 , arg $ "-I" ++ root -/- generatedDir
38 , notM ghcWithSMP ? arg "-DNOSMP"
39 , arg "-fcommon" ]