summaryrefslogtreecommitdiff
path: root/hadrian/src/Expression.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Expression.hs')
-rw-r--r--hadrian/src/Expression.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/hadrian/src/Expression.hs b/hadrian/src/Expression.hs
index db437013b4..0b9c50ef3a 100644
--- a/hadrian/src/Expression.hs
+++ b/hadrian/src/Expression.hs
@@ -8,7 +8,8 @@ module Expression (
expr, exprIO, arg, remove, cabalFlag,
-- ** Predicates
- (?), stage, stage0, stage1, stage2, notStage0, threadedBootstrapper,
+ (?), stage, stage0, stage1, stage2, notStage0, buildingCompilerStage,
+ buildingCompilerStage', threadedBootstrapper,
package, notPackage, packageOneOf, cross, notCross,
libraryPackage, builder, way, input, inputs, output, outputs,
@@ -128,6 +129,16 @@ stage2 = stage Stage2
notStage0 :: Predicate
notStage0 = notM Expression.stage0
+-- | Are we currently building a compiler for a particular stage?
+buildingCompilerStage :: Stage -> Predicate
+buildingCompilerStage s = buildingCompilerStage' (== s)
+
+-- | Like 'buildingCompilerStage', but lifts an arbitrary predicate on 'Stage',
+-- which is useful for checking flavour fields like 'ghcProfiled' and
+-- 'ghcDebugged'.
+buildingCompilerStage' :: (Stage -> Bool) -> Predicate
+buildingCompilerStage' f = f . succStage <$> getStage
+
-- | Whether or not the bootstrapping compiler provides a threaded RTS. We need
-- to know this when building stage 1, since stage 1 links against the