Expression: Don't re-export Base
[hadrian.git] / src / Rules / Generators / GhcBootPlatformH.hs
1 module Rules.Generators.GhcBootPlatformH (generateGhcBootPlatformH) where
2
3 import Base
4 import Expression
5 import Oracles
6
7 generateGhcBootPlatformH :: Expr String
8 generateGhcBootPlatformH = do
9 lift $ need [sourcePath -/- "Rules/Generators/GhcBootPlatformH.hs"]
10 stage <- getStage
11 let cppify = replaceEq '-' '_' . replaceEq '.' '_'
12 chooseSetting x y = getSetting $ if stage == Stage0 then x else y
13 buildPlatform <- chooseSetting BuildPlatform HostPlatform
14 buildArch <- chooseSetting BuildArch HostArch
15 buildOs <- chooseSetting BuildOs HostOs
16 buildVendor <- chooseSetting BuildVendor HostVendor
17 hostPlatform <- chooseSetting HostPlatform TargetPlatform
18 hostArch <- chooseSetting HostArch TargetArch
19 hostOs <- chooseSetting HostOs TargetOs
20 hostVendor <- chooseSetting HostVendor TargetVendor
21 targetPlatform <- getSetting TargetPlatform
22 targetArch <- getSetting TargetArch
23 targetOs <- getSetting TargetOs
24 targetVendor <- getSetting TargetVendor
25 return $ unlines
26 [ "#ifndef __PLATFORM_H__"
27 , "#define __PLATFORM_H__"
28 , ""
29 , "#define BuildPlatform_NAME " ++ quote buildPlatform
30 , "#define HostPlatform_NAME " ++ quote hostPlatform
31 , "#define TargetPlatform_NAME " ++ quote targetPlatform
32 , ""
33 , "#define " ++ cppify buildPlatform ++ "_BUILD 1"
34 , "#define " ++ cppify hostPlatform ++ "_HOST 1"
35 , "#define " ++ cppify targetPlatform ++ "_TARGET 1"
36 , ""
37 , "#define " ++ buildArch ++ "_BUILD_ARCH 1"
38 , "#define " ++ hostArch ++ "_HOST_ARCH 1"
39 , "#define " ++ targetArch ++ "_TARGET_ARCH 1"
40 , "#define BUILD_ARCH " ++ quote buildArch
41 , "#define HOST_ARCH " ++ quote hostArch
42 , "#define TARGET_ARCH " ++ quote targetArch
43 , ""
44 , "#define " ++ buildOs ++ "_BUILD_OS 1"
45 , "#define " ++ hostOs ++ "_HOST_OS 1"
46 , "#define " ++ targetOs ++ "_TARGET_OS 1"
47 , "#define BUILD_OS " ++ quote buildOs
48 , "#define HOST_OS " ++ quote hostOs
49 , "#define TARGET_OS " ++ quote targetOs
50 , ""
51 , "#define " ++ buildVendor ++ "_BUILD_VENDOR 1"
52 , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
53 , "#define " ++ targetVendor ++ "_TARGET_VENDOR 1"
54 , "#define BUILD_VENDOR " ++ quote buildVendor
55 , "#define HOST_VENDOR " ++ quote hostVendor
56 , "#define TARGET_VENDOR " ++ quote targetVendor
57 , ""
58 , "#endif /* __PLATFORM_H__ */" ]