Expression: Don't re-export Base
[hadrian.git] / src / Predicates.hs
1 module Predicates (
2 module GHC,
3 module Oracles.Config.Flag,
4 module Oracles.Config.Setting,
5 stage, package, builder, stagedBuilder, file, way,
6 stage0, stage1, stage2, notStage0, notPackage, registerPackage, splitObjects
7 ) where
8
9 import Base
10 import Expression
11 import GHC
12 import Oracles.Config.Flag
13 import Oracles.Config.Setting
14
15 -- Basic predicates
16 stage :: Stage -> Predicate
17 stage s = fmap (s ==) getStage
18
19 package :: Package -> Predicate
20 package p = fmap (p ==) getPackage
21
22 -- For unstaged builders, e.g. GhcCabal
23 builder :: Builder -> Predicate
24 builder b = fmap (b ==) getBuilder
25
26 -- For staged builders, e.g. Ghc Stage
27 stagedBuilder :: (Stage -> Builder) -> Predicate
28 stagedBuilder sb = (builder . sb) =<< getStage
29
30 file :: FilePattern -> Predicate
31 file f = fmap (any (f ?==)) getOutputs
32
33 way :: Way -> Predicate
34 way w = fmap (w ==) getWay
35
36 -- Derived predicates
37 stage0 :: Predicate
38 stage0 = stage Stage0
39
40 stage1 :: Predicate
41 stage1 = stage Stage1
42
43 stage2 :: Predicate
44 stage2 = stage Stage2
45
46 notStage0 :: Predicate
47 notStage0 = notM stage0
48
49 notPackage :: Package -> Predicate
50 notPackage = notM . package
51
52 -- TODO: Actually, we don't register compiler in some circumstances -- fix.
53 registerPackage :: Predicate
54 registerPackage = return True
55
56 splitObjects :: Predicate
57 splitObjects = do
58 goodStage <- notStage0 -- We don't split bootstrap (stage 0) packages
59 goodPackage <- notM $ package compiler -- We don't split compiler
60 supported <- lift supportsSplitObjects
61 return $ goodStage && goodPackage && supported