| ... |
... |
@@ -10,6 +10,7 @@ import qualified Hadrian.Oracles.Path |
|
10
|
10
|
import qualified Hadrian.Oracles.TextFile
|
|
11
|
11
|
import qualified Hadrian.Haskell.Hash
|
|
12
|
12
|
|
|
|
13
|
+import BindistConfig
|
|
13
|
14
|
import Expression
|
|
14
|
15
|
import qualified Oracles.Flavour
|
|
15
|
16
|
import qualified Oracles.ModuleFiles
|
| ... |
... |
@@ -32,17 +33,49 @@ import Settings.Program (programContext) |
|
32
|
33
|
import Target
|
|
33
|
34
|
import UserSettings
|
|
34
|
35
|
|
|
35
|
|
--- | This rule defines what the default build configuration is when no targets
|
|
36
|
|
--- are selected.
|
|
|
36
|
+-- | This rule calls 'need' on all top-level build targets that Hadrian builds
|
|
|
37
|
+-- by default, respecting the 'finalStage' flag.
|
|
37
|
38
|
topLevelTargets :: Rules ()
|
|
38
|
39
|
topLevelTargets = action $ do
|
|
39
|
|
- let targets = ["binary-dist-dir"]
|
|
|
40
|
+ verbosity <- getVerbosity
|
|
|
41
|
+ forM_ [ Stage1, Stage2, Stage3] $ \stage -> do
|
|
|
42
|
+ when (verbosity >= Verbose) $ do
|
|
|
43
|
+ (libraries, programs) <- partition isLibrary <$> stagePackages stage
|
|
|
44
|
+ libNames <- mapM (name stage) libraries
|
|
|
45
|
+ pgmNames <- mapM (name stage) programs
|
|
|
46
|
+ let stageHeader t ps =
|
|
|
47
|
+ "| Building " ++ show stage ++ " "
|
|
|
48
|
+ ++ t ++ ": " ++ intercalate ", " ps
|
|
|
49
|
+ putInfo . unlines $
|
|
|
50
|
+ [ stageHeader "libraries" libNames
|
|
|
51
|
+ , stageHeader "programs" pgmNames ]
|
|
|
52
|
+ let buildStages = [ s | s <- allStages, s < finalStage ]
|
|
|
53
|
+ targets <- concatForM buildStages $ \stage -> do
|
|
|
54
|
+ packages <- stagePackages stage
|
|
|
55
|
+ mapM (path stage) packages
|
|
|
56
|
+
|
|
|
57
|
+ -- For cross compilers, also build the target (stage 2) libraries.
|
|
|
58
|
+ cfg <- implicitBindistConfig
|
|
|
59
|
+ lib_targets <- if executable_stage cfg < finalStage
|
|
|
60
|
+ then map snd . fst <$> Rules.BinaryDist.bindistPackageTargets cfg
|
|
|
61
|
+ else return []
|
|
40
|
62
|
|
|
41
|
63
|
-- Why we need wrappers: https://gitlab.haskell.org/ghc/ghc/issues/16534.
|
|
42
|
64
|
root <- buildRoot
|
|
43
|
65
|
let wrappers = [ root -/- ("ghc-" ++ stageString s) | s <- [Stage1, Stage2, Stage3]
|
|
44
|
66
|
, s < finalStage ]
|
|
45
|
|
- need (targets ++ wrappers)
|
|
|
67
|
+ need (targets ++ lib_targets ++ wrappers)
|
|
|
68
|
+ where
|
|
|
69
|
+ -- either the package database config file for libraries or
|
|
|
70
|
+ -- the programPath for programs. However this still does
|
|
|
71
|
+ -- not support multiple targets, where a cabal package has
|
|
|
72
|
+ -- a library /and/ a program.
|
|
|
73
|
+ path :: Stage -> Package -> Action FilePath
|
|
|
74
|
+ path stage pkg | isLibrary pkg = pkgConfFile (vanillaContext stage pkg)
|
|
|
75
|
+ | otherwise = programPath =<< programContext stage pkg
|
|
|
76
|
+ name :: Stage -> Package -> Action String
|
|
|
77
|
+ name stage pkg | isLibrary pkg = return (pkgName pkg)
|
|
|
78
|
+ | otherwise = programName (vanillaContext stage pkg)
|
|
46
|
79
|
|
|
47
|
80
|
-- | Return the list of targets associated with a given 'Stage' and 'Package'.
|
|
48
|
81
|
packageTargets :: Stage -> Package -> Action [FilePath]
|