Remove more validation errors (#628)
[hadrian.git] / src / Oracles / TestSettings.hs
1 -- | We create a file <root>/test/ghcconfig containing configuration of test
2 -- | compiler. We need to search this file for required keys and setting
3 -- | required for testsuite e.g. WORDSIZE, HOSTOS etc.
4
5 module Oracles.TestSettings (
6 TestSetting (..), testSetting, testRTSSettings
7 ) where
8
9 import Hadrian.Oracles.TextFile
10 import Base
11
12 testConfigFile :: Action FilePath
13 testConfigFile = buildRoot <&> (-/- "test/ghcconfig")
14
15 -- | Test settings that are obtained from ghcconfig file.
16 data TestSetting = TestHostOS
17 | TestWORDSIZE
18 | TestTARGETPLATFORM
19 | TestTargetOS_CPP
20 | TestTargetARCH_CPP
21 | TestGhcStage
22 | TestGhcDebugged
23 | TestGhcWithNativeCodeGen
24 | TestGhcWithInterpreter
25 | TestGhcUnregisterised
26 | TestGhcWithSMP
27 | TestGhcDynamicByDefault
28 | TestGhcDynamic
29 | TestGhcProfiled
30 | TestAR
31 | TestCLANG
32 | TestLLC
33 | TestTEST_CC
34 | TestGhcPackageDbFlag
35 | TestMinGhcVersion711
36 | TestMinGhcVersion801
37 deriving (Show)
38
39 -- | Lookup for testsettings in ghcconfig file
40 -- | To obtain RTS Ways supported in ghcconfig file, use testRTSSettings.
41 testSetting :: TestSetting -> Action String
42 testSetting key = do
43 file <- testConfigFile
44 lookupValueOrError file $ case key of
45 TestHostOS -> "HostOS"
46 TestWORDSIZE -> "WORDSIZE"
47 TestTARGETPLATFORM -> "TARGETPLATFORM"
48 TestTargetOS_CPP -> "TargetOS_CPP"
49 TestTargetARCH_CPP -> "TargetARCH_CPP"
50 TestGhcStage -> "GhcStage"
51 TestGhcDebugged -> "GhcDebugged"
52 TestGhcWithNativeCodeGen -> "GhcWithNativeCodeGen"
53 TestGhcWithInterpreter -> "GhcWithInterpreter"
54 TestGhcUnregisterised -> "GhcUnregisterised"
55 TestGhcWithSMP -> "GhcWithSMP"
56 TestGhcDynamicByDefault -> "GhcDynamicByDefault"
57 TestGhcDynamic -> "GhcDynamic"
58 TestGhcProfiled -> "GhcProfiled"
59 TestAR -> "AR"
60 TestCLANG -> "CLANG"
61 TestLLC -> "LLC"
62 TestTEST_CC -> "TEST_CC"
63 TestGhcPackageDbFlag -> "GhcPackageDbFlag"
64 TestMinGhcVersion711 -> "MinGhcVersion711"
65 TestMinGhcVersion801 -> "MinGhcVersion801"
66
67
68 -- | Get the RTS ways of the test compiler
69 testRTSSettings :: Action [String]
70 testRTSSettings = do
71 file <- testConfigFile
72 fmap words $ lookupValueOrError file "GhcRTSWays"
73