DeriveConstants.hs 1.51 KB
Newer Older
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 7
deriveConstantsBuilderArgs :: Args
deriveConstantsBuilderArgs = builder DeriveConstants ? do
8
    cFlags                <- includeCcArgs
9
    [outputFile, tempDir] <- getOutputs
10
    mconcat
11 12 13 14 15 16
        [ output "//DerivedConstants.h"             ? arg "--gen-header"
        , output "//GHCConstantsHaskellType.hs"     ? arg "--gen-haskell-type"
        , output "//platformConstants"              ? arg "--gen-haskell-value"
        , output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
        , output "//GHCConstantsHaskellExports.hs"  ? arg "--gen-haskell-exports"
        , arg "-o", arg outputFile
17
        , arg "--tmpdir", arg tempDir
18
        , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
Andrey Mokhov's avatar
Andrey Mokhov committed
19
        , pure $ concatMap (\a -> ["--gcc-flag", a]) cFlags
20
        , arg "--nm-program", arg =<< getBuilderPath Nm
21 22
        , isSpecified Objdump ? mconcat [ arg "--objdump-program"
                                        , arg =<< getBuilderPath Objdump ]
Andrey Mokhov's avatar
Andrey Mokhov committed
23
        , arg "--target-os", arg =<< getSetting TargetOs ]
24 25

includeCcArgs :: Args
26 27 28
includeCcArgs = mconcat
    [ cArgs
    , cWarnings
29
    , getSettingList $ ConfCcArgs Stage1
30 31 32
    , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
    , arg "-Irts"
    , arg "-Iincludes"
Andrey Mokhov's avatar
Andrey Mokhov committed
33
    , arg $ "-I" ++ generatedPath
34 35
    , notM ghcWithSMP ? arg "-DNOSMP"
    , arg "-fcommon" ]