1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
module Settings.Builders.DeriveConstants (
deriveConstantsBuilderArgs, deriveConstantsPairs
) where
import Builder
import Settings.Builders.Common
deriveConstantsPairs :: [(String, String)]
deriveConstantsPairs =
[ ("DerivedConstants.h", "--gen-header")
, ("GHCConstantsHaskellType.hs", "--gen-haskell-type")
, ("platformConstants", "--gen-haskell-value")
, ("GHCConstantsHaskellWrappers.hs", "--gen-haskell-wrappers")
, ("GHCConstantsHaskellExports.hs", "--gen-haskell-exports")
]
-- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
deriveConstantsBuilderArgs :: Args
deriveConstantsBuilderArgs = builder DeriveConstants ? do
cFlags <- includeCcArgs
outs <- getOutputs
let (outputFile, mode, tempDir) = case outs of
[ofile, mode, tmpdir] -> (ofile,mode,tmpdir)
[ofile, tmpdir]
| Just mode <- lookup (takeFileName ofile) deriveConstantsPairs
-> (ofile, mode, tmpdir)
| otherwise
-> error $ "DeriveConstants: invalid output file, got " ++ show (takeFileName ofile)
_ -> error $ "DeriveConstants: unexpected outputs, got " ++ show outs
mconcat
[ arg mode
, arg "-o", arg outputFile
, arg "--tmpdir", arg tempDir
, arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
, pure $ concatMap (\a -> ["--gcc-flag", a]) cFlags
, arg "--nm-program", arg =<< getBuilderPath Nm
, isSpecified Objdump ? mconcat [ arg "--objdump-program"
, arg =<< getBuilderPath Objdump ]
, arg "--target-os", arg =<< getSetting TargetOs ]
includeCcArgs :: Args
includeCcArgs = do
stage <- getStage
libPath <- expr $ stageLibPath stage
mconcat [ cArgs
, cWarnings
, getSettingList $ ConfCcArgs Stage1
, flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
, arg "-Irts"
, arg "-Iincludes"
, arg $ "-I" ++ libPath
, notM targetSupportsSMP ? arg "-DNOSMP"
, arg "-fcommon" ]
|