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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
module Settings.Default (
-- * Packages that are build by default and for the testsuite
defaultPackages, testsuitePackages, stage0Packages,
-- * Default build ways
defaultLibraryWays, defaultRtsWays,
-- * Default command line arguments for various builders
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultArgs,
-- * Default build flavour and BigNum backend
defaultFlavour, defaultBignumBackend
) where
import qualified Data.Set as Set
import qualified Hadrian.Builder.Sphinx
import qualified Hadrian.Builder.Tar
import Hadrian.Haskell.Cabal.Type
import CommandLine
import Expression
import Flavour.Type
import Oracles.Flag
import Oracles.Setting
import Packages
import Settings.Builders.Alex
import Settings.Builders.DeriveConstants
import Settings.Builders.Cabal
import Settings.Builders.Cc
import Settings.Builders.Configure
import Settings.Builders.GenPrimopCode
import Settings.Builders.Ghc
import Settings.Builders.GhcPkg
import Settings.Builders.Haddock
import Settings.Builders.Happy
import Settings.Builders.Hsc2Hs
import Settings.Builders.HsCpp
import Settings.Builders.Ar
import Settings.Builders.Ld
import Settings.Builders.Make
import Settings.Builders.MergeObjects
import Settings.Builders.SplitSections
import Settings.Builders.RunTest
import Settings.Builders.Xelatex
import Settings.Packages
import Settings.Warnings
import qualified Hadrian.Builder.Git
import Settings.Builders.Win32Tarballs
-- | Packages that are built by default. You can change this in "UserSettings".
defaultPackages :: Stage -> Action [Package]
defaultPackages (Stage0 GlobalLibs) = stageBootPackages
defaultPackages (Stage0 InTreeLibs) = stage0Packages
defaultPackages Stage1 = stage1Packages
defaultPackages Stage2 = stage2Packages
defaultPackages Stage3 = return []
-- | Default bignum backend.
defaultBignumBackend :: String
defaultBignumBackend = "gmp"
-- These packages are things needed to do the build.. so they are only built by
-- boot compiler, with global package database. By default we will only build these
-- packages in StageBoot so if you also need to distribute anything here then add
-- it to `stage0packages` or `stage1packages` as appropiate.
stageBootPackages :: Action [Package]
stageBootPackages = return [lintersCommon, lintCommitMsg, lintSubmoduleRefs, lintWhitespace, lintNotes, hsc2hs, compareSizes, deriveConstants, genapply, genprimopcode, unlit ]
-- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
stage0Packages :: Action [Package]
stage0Packages = do
cross <- flag CrossCompiling
return $ [ binary
, bytestring
, cabalSyntax
, cabal
, compiler
, containers
, directory
, process
, exceptions
, filepath
, ghc
, runGhc
, ghcBoot
, ghcBootTh
, ghcHeap
, ghci
, ghcPkg
, haddock
, hsc2hs
, hpc
, hpcBin
, mtl
, parsec
, time
, templateHaskell
, text
, transformers
, unlit
, hp2ps
, if windowsHost then win32 else unix
]
++ [ terminfo | not windowsHost, not cross ]
++ [ timeout | windowsHost ]
++ [ touchy | windowsHost ]
-- | Packages built in 'Stage1' by default. You can change this in "UserSettings".
stage1Packages :: Action [Package]
stage1Packages = do
let good_stage0_package p
-- we only keep libraries for some reason
| not (isLibrary p) = False
-- but not win32/unix because it depends on cross-compilation target
| p == win32 = False
| p == unix = False
| otherwise = True
libraries0 <- filter good_stage0_package <$> stage0Packages
cross <- flag CrossCompiling
winTarget <- isWinTarget
let when c xs = if c then xs else mempty
return $ mconcat
[ libraries0 -- Build all Stage0 libraries in Stage1
, [ array
, base
, containers
, deepseq
, exceptions
, ghc
, ghcBignum
, ghcCompact
, ghcPkg
, ghcPrim
, haskeline
, hp2ps
, hsc2hs
, integerGmp
, pretty
, rts
, stm
, unlit
, xhtml
, if winTarget then win32 else unix
]
, when (not cross)
[ haddock
, hpcBin
, iserv
, libiserv
, runGhc
]
, when (winTarget && not cross)
[ touchy
-- See Note [Hadrian's ghci-wrapper package]
, ghciWrapper
]
]
-- | Packages built in 'Stage2' by default. You can change this in "UserSettings".
stage2Packages :: Action [Package]
stage2Packages = stage1Packages
-- | Packages that are built only for the testsuite.
testsuitePackages :: Action [Package]
testsuitePackages = return ([ timeout | windowsHost ] ++ [ checkPpr, checkExact, countDeps, ghcConfig ])
-- | Default build ways for library packages:
-- * We always build 'vanilla' way.
-- * We build 'profiling' way when stage > Stage0.
-- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
defaultLibraryWays :: Ways
defaultLibraryWays = Set.fromList <$>
mconcat
[ pure [vanilla]
, notStage0 ? pure [profiling]
, notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
]
-- | Default build ways for the RTS.
defaultRtsWays :: Ways
defaultRtsWays = Set.fromList <$>
mconcat
[ pure [vanilla]
, notStage0 ? pure
[ profiling, debugProfiling
, debug
]
, notStage0 ? targetSupportsThreadedRts ? pure [threaded, threadedProfiling, threadedDebugProfiling, threadedDebug]
, notStage0 ? platformSupportsSharedLibs ? pure
[ dynamic, debugDynamic
]
, notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure [ threadedDynamic, threadedDebugDynamic ]
]
-- TODO: Move C source arguments here
-- | Default and package-specific source arguments.
data SourceArgs = SourceArgs
{ hsDefault :: Args
, hsLibrary :: Args
, hsCompiler :: Args
, hsGhc :: Args }
-- | Concatenate source arguments in appropriate order.
sourceArgs :: SourceArgs -> Args
sourceArgs SourceArgs {..} = builder Ghc ? mconcat
[ hsDefault
, getContextData hcOpts
-- `compiler` is also a library but the specific arguments that we want
-- to apply to that are given by the hsCompiler option. `ghc` is an
-- executable so we don't have to exclude that.
, libraryPackage ? notM (packageOneOf [compiler]) ? hsLibrary
, package compiler ? hsCompiler
, package ghc ? hsGhc ]
-- | All default command line arguments.
defaultArgs :: Args
defaultArgs = mconcat
[ defaultBuilderArgs
, sourceArgs defaultSourceArgs
, defaultPackageArgs ]
-- | Default source arguments, e.g. optimisation settings.
defaultSourceArgs :: SourceArgs
defaultSourceArgs = SourceArgs
{ hsDefault = mconcat [ stage0 ? arg "-O"
, notStage0 ? arg "-O2"
, arg "-H32m" ]
, hsLibrary = notStage0 ? arg "-haddock"
, hsCompiler = mempty
, hsGhc = mempty }
-- Please update doc/flavours.md when changing the default build flavour.
-- | Default build flavour. Other build flavours are defined in modules
-- @Settings.Flavours.*@. Users can add new build flavours in "UserSettings".
defaultFlavour :: Flavour
defaultFlavour = Flavour
{ name = "default"
, args = defaultArgs
, packages = defaultPackages
, bignumBackend = defaultBignumBackend
, bignumCheck = False
, libraryWays = defaultLibraryWays
, rtsWays = defaultRtsWays
, dynamicGhcPrograms = defaultDynamicGhcPrograms
, ghciWithDebugger = const False
, ghcProfiled = const False
, ghcDebugged = const False
, ghcThreaded = const True
, ghcDebugAssertions = const False
, ghcSplitSections = False
, ghcDocs = cmdDocsArgs }
-- | Default logic for determining whether to build
-- dynamic GHC programs.
--
-- It corresponds to the DYNAMIC_GHC_PROGRAMS logic implemented
-- in @mk/config.mk.in@.
defaultDynamicGhcPrograms :: Action Bool
defaultDynamicGhcPrograms = do
supportsShared <- platformSupportsSharedLibs
return (not windowsHost && supportsShared)
-- | All 'Builder'-dependent command line arguments.
defaultBuilderArgs :: Args
defaultBuilderArgs = mconcat
-- GHC-specific builders:
[ alexBuilderArgs
, cabalBuilderArgs
, ccBuilderArgs
, configureBuilderArgs
, deriveConstantsBuilderArgs
, genPrimopCodeBuilderArgs
, ghcBuilderArgs
, ghcPkgBuilderArgs
, haddockBuilderArgs
, happyBuilderArgs
, hsc2hsBuilderArgs
, hsCppBuilderArgs
, ldBuilderArgs
, arBuilderArgs
, makeBuilderArgs
, mergeObjectsBuilderArgs
, runTestBuilderArgs
, validateBuilderArgs
, xelatexBuilderArgs
, win32TarballsArgs
, splitSectionsArgs
-- Generic builders from the Hadrian library:
, builder (Sphinx HtmlMode ) ? Hadrian.Builder.Sphinx.args HtmlMode
, builder (Sphinx LatexMode) ? Hadrian.Builder.Sphinx.args LatexMode
, builder (Sphinx ManMode ) ? Hadrian.Builder.Sphinx.args ManMode
, builder (Sphinx InfoMode ) ? Hadrian.Builder.Sphinx.args InfoMode
, builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
, builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract
, Hadrian.Builder.Git.gitArgs
]
-- | All 'Package'-dependent command line arguments.
defaultPackageArgs :: Args
defaultPackageArgs = mconcat [ packageArgs
, builder Ghc ? ghcWarningsArgs ]
|