Make build badges more informative
[hadrian.git] / src / Predicates.hs
1 -- | Convenient predicates
2 module Predicates (
3 stage, package, builder, stagedBuilder, builderGcc, builderGhc, file, way,
4 stage0, stage1, stage2, notStage0, notPackage, registerPackage
5 ) where
6
7 import Base
8 import Expression
9
10 -- | Is the build currently in the provided stage?
11 stage :: Stage -> Predicate
12 stage s = fmap (s ==) getStage
13
14 -- | Is a particular package being built?
15 package :: Package -> Predicate
16 package p = fmap (p ==) getPackage
17
18 -- | Is an unstaged builder is being used such as /GhcCabal/?
19 builder :: Builder -> Predicate
20 builder b = fmap (b ==) getBuilder
21
22 -- | Is a certain builder used in the current stage?
23 stagedBuilder :: (Stage -> Builder) -> Predicate
24 stagedBuilder stageBuilder = do
25 s <- getStage
26 builder (stageBuilder s)
27
28 -- | Are we building with GCC?
29 builderGcc :: Predicate
30 builderGcc = stagedBuilder Gcc ||^ stagedBuilder GccM
31
32 -- | Are we building with GHC?
33 builderGhc :: Predicate
34 builderGhc = stagedBuilder Ghc ||^ stagedBuilder GhcM
35
36 -- | Does any of the output files match a given pattern?
37 file :: FilePattern -> Predicate
38 file f = fmap (any (f ?==)) getOutputs
39
40 -- | Is the current build 'Way' equal to a certain value?
41 way :: Way -> Predicate
42 way w = fmap (w ==) getWay
43
44 -- | Is the build currently in stage 0?
45 stage0 :: Predicate
46 stage0 = stage Stage0
47
48 -- | Is the build currently in stage 1?
49 stage1 :: Predicate
50 stage1 = stage Stage1
51
52 -- | Is the build currently in stage 2?
53 stage2 :: Predicate
54 stage2 = stage Stage2
55
56 -- | Is the build /not/ in stage 0 right now?
57 notStage0 :: Predicate
58 notStage0 = notM stage0
59
60 -- | Is a certain package /not/ built right now?
61 notPackage :: Package -> Predicate
62 notPackage = notM . package
63
64 -- TODO: Actually, we don't register compiler in some circumstances -- fix.
65 -- | Do we need to run @ghc-pkg update@ on the currently built package?
66 -- See "Rules.Data".
67 registerPackage :: Predicate
68 registerPackage = return True