summaryrefslogtreecommitdiff
path: root/hadrian/src/Settings/Program.hs
blob: 46bbcb1709674b000aee5b2a02b1f71c7afac320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 && notStage0 stage = profiling
            | dyn && notStage0 stage                = dynamic
            | otherwise                            = vanilla

          notStage0 (Stage0 {}) = False
          notStage0 _ = True