c5ad0ccad90daedf62e12c6a4c1f401368718b0b
[hadrian.git] / src / Rules / Generators / ConfigHs.hs
1 module Rules.Generators.ConfigHs (generateConfigHs) where
2
3 import Base
4 import Expression
5 import Flavour
6 import GHC
7 import Oracles.Config.Flag
8 import Oracles.Config.Setting
9 import Rules.Generators.Common
10 import Settings
11 import UserSettings
12
13 generateConfigHs :: Expr String
14 generateConfigHs = do
15 trackSource "Rules/Generators/ConfigHs.hs"
16 cProjectName <- getSetting ProjectName
17 cProjectGitCommitId <- getSetting ProjectGitCommitId
18 cProjectVersion <- getSetting ProjectVersion
19 cProjectVersionInt <- getSetting ProjectVersionInt
20 cProjectPatchLevel <- getSetting ProjectPatchLevel
21 cProjectPatchLevel1 <- getSetting ProjectPatchLevel1
22 cProjectPatchLevel2 <- getSetting ProjectPatchLevel2
23 cBooterVersion <- getSetting GhcVersion
24 let cIntegerLibraryType | integerLibrary == integerGmp = "IntegerGMP"
25 | integerLibrary == integerSimple = "IntegerSimple"
26 | otherwise = error $ "Unknown integer library: "
27 ++ show integerLibrary ++ "."
28 cSupportsSplitObjs <- yesNo supportsSplitObjects
29 cGhcWithInterpreter <- yesNo ghcWithInterpreter
30 cGhcWithNativeCodeGen <- yesNo ghcWithNativeCodeGen
31 cGhcWithSMP <- yesNo ghcWithSMP
32 cGhcEnableTablesNextToCode <- yesNo ghcEnableTablesNextToCode
33 cLeadingUnderscore <- yesNo $ flag LeadingUnderscore
34 cGHC_UNLIT_PGM <- fmap takeFileName $ getBuilderPath Unlit
35 cLibFFI <- lift useLibFFIForAdjustors
36 rtsWays <- getRtsWays
37 cGhcRtsWithLibdw <- getFlag WithLibdw
38 let cGhcRTSWays = unwords $ map show rtsWays
39 return $ unlines
40 [ "{-# LANGUAGE CPP #-}"
41 , "module Config where"
42 , ""
43 , "#include \"ghc_boot_platform.h\""
44 , ""
45 , "data IntegerLibrary = IntegerGMP"
46 , " | IntegerSimple"
47 , " deriving Eq"
48 , ""
49 , "cBuildPlatformString :: String"
50 , "cBuildPlatformString = BuildPlatform_NAME"
51 , "cHostPlatformString :: String"
52 , "cHostPlatformString = HostPlatform_NAME"
53 , "cTargetPlatformString :: String"
54 , "cTargetPlatformString = TargetPlatform_NAME"
55 , ""
56 , "cProjectName :: String"
57 , "cProjectName = " ++ show cProjectName
58 , "cProjectGitCommitId :: String"
59 , "cProjectGitCommitId = " ++ show cProjectGitCommitId
60 , "cProjectVersion :: String"
61 , "cProjectVersion = " ++ show cProjectVersion
62 , "cProjectVersionInt :: String"
63 , "cProjectVersionInt = " ++ show cProjectVersionInt
64 , "cProjectPatchLevel :: String"
65 , "cProjectPatchLevel = " ++ show cProjectPatchLevel
66 , "cProjectPatchLevel1 :: String"
67 , "cProjectPatchLevel1 = " ++ show cProjectPatchLevel1
68 , "cProjectPatchLevel2 :: String"
69 , "cProjectPatchLevel2 = " ++ show cProjectPatchLevel2
70 , "cBooterVersion :: String"
71 , "cBooterVersion = " ++ show cBooterVersion
72 , "cStage :: String"
73 , "cStage = show (STAGE :: Int)"
74 , "cIntegerLibrary :: String"
75 , "cIntegerLibrary = " ++ show (pkgNameString integerLibrary)
76 , "cIntegerLibraryType :: IntegerLibrary"
77 , "cIntegerLibraryType = " ++ cIntegerLibraryType
78 , "cSupportsSplitObjs :: String"
79 , "cSupportsSplitObjs = " ++ show cSupportsSplitObjs
80 , "cGhcWithInterpreter :: String"
81 , "cGhcWithInterpreter = " ++ show cGhcWithInterpreter
82 , "cGhcWithNativeCodeGen :: String"
83 , "cGhcWithNativeCodeGen = " ++ show cGhcWithNativeCodeGen
84 , "cGhcWithSMP :: String"
85 , "cGhcWithSMP = " ++ show cGhcWithSMP
86 , "cGhcRTSWays :: String"
87 , "cGhcRTSWays = " ++ show cGhcRTSWays
88 , "cGhcEnableTablesNextToCode :: String"
89 , "cGhcEnableTablesNextToCode = " ++ show cGhcEnableTablesNextToCode
90 , "cLeadingUnderscore :: String"
91 , "cLeadingUnderscore = " ++ show cLeadingUnderscore
92 , "cGHC_UNLIT_PGM :: String"
93 , "cGHC_UNLIT_PGM = " ++ show cGHC_UNLIT_PGM
94 , "cGHC_SPLIT_PGM :: String"
95 , "cGHC_SPLIT_PGM = " ++ show "ghc-split"
96 , "cLibFFI :: Bool"
97 , "cLibFFI = " ++ show cLibFFI
98 , "cGhcThreaded :: Bool"
99 , "cGhcThreaded = " ++ show (threaded `elem` rtsWays)
100 , "cGhcDebugged :: Bool"
101 , "cGhcDebugged = " ++ show (ghcDebugged flavour)
102 , "cGhcRtsWithLibdw :: Bool"
103 , "cGhcRtsWithLibdw = " ++ show cGhcRtsWithLibdw ]