Refactor oracles, add comments.
[hadrian.git] / src / Oracles / Flag.hs
1 module Oracles.Flag (
2 Flag (..),
3 test
4 ) where
5
6 import Util
7 import Oracles.Base
8
9 data Flag = LaxDeps
10 | DynamicGhcPrograms
11 | GccIsClang
12 | GccLt46
13 | CrossCompiling
14 | Validating
15 | SupportsPackageKey
16 | SolarisBrokenShld
17 | SplitObjectsBroken
18 | GhcUnregisterised
19
20 -- TODO: Give the warning *only once* per key
21 test :: Flag -> Action Bool
22 test flag = do
23 (key, defaultValue) <- return $ case flag of
24 LaxDeps -> ("lax-dependencies" , False)
25 DynamicGhcPrograms -> ("dynamic-ghc-programs" , False)
26 GccIsClang -> ("gcc-is-clang" , False)
27 GccLt46 -> ("gcc-lt-46" , False)
28 CrossCompiling -> ("cross-compiling" , False)
29 Validating -> ("validating" , False)
30 SupportsPackageKey -> ("supports-package-key" , False)
31 SolarisBrokenShld -> ("solaris-broken-shld" , False)
32 SplitObjectsBroken -> ("split-objects-broken" , False)
33 GhcUnregisterised -> ("ghc-unregisterised" , False)
34 let defaultString = if defaultValue then "YES" else "NO"
35 value <- askConfigWithDefault key $ -- TODO: warn just once
36 do putColoured Red $ "\nFlag '"
37 ++ key
38 ++ "' not set in configuration files. "
39 ++ "Proceeding with default value '"
40 ++ defaultString
41 ++ "'.\n"
42 return defaultString
43 return $ value == "YES"