summaryrefslogtreecommitdiff
path: root/hadrian/src/Settings/Program.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Settings/Program.hs')
-rw-r--r--hadrian/src/Settings/Program.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/hadrian/src/Settings/Program.hs b/hadrian/src/Settings/Program.hs
new file mode 100644
index 0000000000..d98b1a9327
--- /dev/null
+++ b/hadrian/src/Settings/Program.hs
@@ -0,0 +1,24 @@
+module Settings.Program
+ ( programContext
+ ) where
+
+import Base
+import Context
+import Oracles.Flavour
+import Packages
+
+-- TODO: there is duplication and inconsistency between this and
+-- Rules.Program.getProgramContexts. There should only be one way to
+-- get a context/contexts for a given stage and package.
+programContext :: Stage -> Package -> Action Context
+programContext stage pkg = do
+ profiled <- askGhcProfiled
+ dynGhcProgs <- askDynGhcPrograms --dynamicGhcPrograms =<< flavour
+ return $ Context stage pkg (wayFor profiled dynGhcProgs)
+
+ where wayFor prof dyn
+ | prof && dyn =
+ error "programContext: profiling+dynamic not supported"
+ | pkg == ghc && prof && stage > Stage0 = profiling
+ | dyn && stage > Stage0 = dynamic
+ | otherwise = vanilla