de5261372a0650661e64f024fbe56ead2b4aa94f
[ghc.git] / hadrian / src / Settings / Default.hs
1 module Settings.Default (
2 -- * Packages that are build by default and for the testsuite
3 defaultPackages, testsuitePackages,
4
5 -- * Default build ways
6 defaultLibraryWays, defaultRtsWays,
7
8 -- * Default command line arguments for various builders
9 SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
10 defaultArgs,
11
12 -- * Default build flavour
13 defaultFlavour, defaultSplitObjects
14 ) where
15
16 import qualified Hadrian.Builder.Ar
17 import qualified Hadrian.Builder.Sphinx
18 import qualified Hadrian.Builder.Tar
19 import Hadrian.Haskell.Cabal.Type
20
21 import CommandLine
22 import Expression
23 import Flavour
24 import Oracles.Flag
25 import Oracles.Setting
26 import Packages
27 import Settings
28 import Settings.Builders.Alex
29 import Settings.Builders.DeriveConstants
30 import Settings.Builders.Cabal
31 import Settings.Builders.Cc
32 import Settings.Builders.Configure
33 import Settings.Builders.GenPrimopCode
34 import Settings.Builders.Ghc
35 import Settings.Builders.GhcPkg
36 import Settings.Builders.Haddock
37 import Settings.Builders.Happy
38 import Settings.Builders.Hsc2Hs
39 import Settings.Builders.HsCpp
40 import Settings.Builders.Ld
41 import Settings.Builders.Make
42 import Settings.Builders.RunTest
43 import Settings.Builders.Xelatex
44 import Settings.Packages
45 import Settings.Warnings
46
47 -- | Packages that are built by default. You can change this in "UserSettings".
48 defaultPackages :: Stage -> Action [Package]
49 defaultPackages Stage0 = stage0Packages
50 defaultPackages Stage1 = stage1Packages
51 defaultPackages Stage2 = stage2Packages
52 defaultPackages Stage3 = return []
53
54 -- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
55 stage0Packages :: Action [Package]
56 stage0Packages = do
57 win <- windowsHost
58 cross <- flag CrossCompiling
59 return $ [ binary
60 , cabal
61 , compareSizes
62 , compiler
63 , deriveConstants
64 , genapply
65 , genprimopcode
66 , ghc
67 , ghcBoot
68 , ghcBootTh
69 , ghcHeap
70 , ghci
71 , ghcPkg
72 , hsc2hs
73 , hpc
74 , mtl
75 , parsec
76 , templateHaskell
77 , text
78 , transformers
79 , unlit ]
80 ++ [ terminfo | not win, not cross ]
81 ++ [ touchy | win ]
82
83 -- | Packages built in 'Stage1' by default. You can change this in "UserSettings".
84 stage1Packages :: Action [Package]
85 stage1Packages = do
86 win <- windowsHost
87 intLib <- integerLibrary =<< flavour
88 libraries0 <- filter isLibrary <$> stage0Packages
89 cross <- flag CrossCompiling
90 return $ libraries0 -- Build all Stage0 libraries in Stage1
91 ++ [ array
92 , base
93 , bytestring
94 , containers
95 , deepseq
96 , directory
97 , filepath
98 , ghc
99 , ghcCompact
100 , ghcPkg
101 , ghcPrim
102 , haskeline
103 , hsc2hs
104 , intLib
105 , pretty
106 , process
107 , rts
108 , stm
109 , time
110 , unlit
111 , xhtml
112 ]
113 ++ [ haddock | not cross ]
114 ++ [ hpcBin | not cross ]
115 ++ [ iserv | not win, not cross ]
116 ++ [ libiserv | not win, not cross ]
117 ++ [ runGhc | not cross ]
118 ++ [ touchy | win ]
119 ++ [ unix | not win ]
120 ++ [ win32 | win ]
121
122 -- | Packages built in 'Stage2' by default. You can change this in "UserSettings".
123 stage2Packages :: Action [Package]
124 stage2Packages = stage1Packages
125
126 -- | Packages that are built only for the testsuite.
127 testsuitePackages :: Action [Package]
128 testsuitePackages = do
129 win <- windowsHost
130 return $ [ checkApiAnnotations
131 , checkPpr
132 , ghci
133 , ghcCompact
134 , ghcPkg
135 , hp2ps
136 , hsc2hs
137 , iserv
138 , runGhc
139 , unlit ] ++
140 [ timeout | win ]
141
142 -- | Default build ways for library packages:
143 -- * We always build 'vanilla' way.
144 -- * We build 'profiling' way when stage > Stage0.
145 -- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
146 defaultLibraryWays :: Ways
147 defaultLibraryWays = mconcat
148 [ pure [vanilla]
149 , notStage0 ? pure [profiling]
150 , notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
151 ]
152
153 -- | Default build ways for the RTS.
154 defaultRtsWays :: Ways
155 defaultRtsWays = mconcat
156 [ pure [vanilla, threaded]
157 , notStage0 ? pure
158 [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling
159 , logging, threadedLogging
160 , debug, threadedDebug
161 ]
162 , notStage0 ? platformSupportsSharedLibs ? pure
163 [ dynamic, threadedDynamic, debugDynamic, loggingDynamic
164 , threadedDebugDynamic, threadedLoggingDynamic
165 ]
166 ]
167
168 -- TODO: Move C source arguments here
169 -- | Default and package-specific source arguments.
170 data SourceArgs = SourceArgs
171 { hsDefault :: Args
172 , hsLibrary :: Args
173 , hsCompiler :: Args
174 , hsGhc :: Args }
175
176 -- | Concatenate source arguments in appropriate order.
177 sourceArgs :: SourceArgs -> Args
178 sourceArgs SourceArgs {..} = builder Ghc ? mconcat
179 [ hsDefault
180 , getContextData hcOpts
181 , libraryPackage ? hsLibrary
182 , package compiler ? hsCompiler
183 , package ghc ? hsGhc ]
184
185 -- | All default command line arguments.
186 defaultArgs :: Args
187 defaultArgs = mconcat
188 [ defaultBuilderArgs
189 , sourceArgs defaultSourceArgs
190 , defaultPackageArgs ]
191
192 -- | Default source arguments, e.g. optimisation settings.
193 defaultSourceArgs :: SourceArgs
194 defaultSourceArgs = SourceArgs
195 { hsDefault = mconcat [ stage0 ? arg "-O"
196 , notStage0 ? arg "-O2"
197 , arg "-H32m" ]
198 , hsLibrary = mempty
199 , hsCompiler = mempty
200 , hsGhc = mempty }
201
202 -- Please update doc/flavours.md when changing the default build flavour.
203 -- | Default build flavour. Other build flavours are defined in modules
204 -- @Settings.Flavours.*@. Users can add new build flavours in "UserSettings".
205 defaultFlavour :: Flavour
206 defaultFlavour = Flavour
207 { name = "default"
208 , args = defaultArgs
209 , packages = defaultPackages
210 , integerLibrary = (\x -> if x then integerSimple else integerGmp) <$> cmdIntegerSimple
211 , libraryWays = defaultLibraryWays
212 , rtsWays = defaultRtsWays
213 , splitObjects = defaultSplitObjects
214 , dynamicGhcPrograms = defaultDynamicGhcPrograms
215 , ghciWithDebugger = False
216 , ghcProfiled = False
217 , ghcDebugged = False }
218
219 -- | Default logic for determining whether to build
220 -- dynamic GHC programs.
221 --
222 -- It corresponds to the DYNAMIC_GHC_PROGRAMS logic implemented
223 -- in @mk/config.mk.in@.
224 defaultDynamicGhcPrograms :: Action Bool
225 defaultDynamicGhcPrograms = do
226 win <- windowsHost
227 supportsShared <- platformSupportsSharedLibs
228 return (not win && supportsShared)
229
230 -- | Default condition for building split objects.
231 defaultSplitObjects :: Predicate
232 defaultSplitObjects = do
233 goodStage <- notStage0 -- We don't split bootstrap (stage 0) packages
234 pkg <- getPackage
235 supported <- expr supportsSplitObjects
236 split <- expr cmdSplitObjects
237 let goodPackage = isLibrary pkg && pkg /= compiler && pkg /= rts
238 return $ split && goodStage && goodPackage && supported
239
240 -- | All 'Builder'-dependent command line arguments.
241 defaultBuilderArgs :: Args
242 defaultBuilderArgs = mconcat
243 -- GHC-specific builders:
244 [ alexBuilderArgs
245 , cabalBuilderArgs
246 , ccBuilderArgs
247 , configureBuilderArgs
248 , deriveConstantsBuilderArgs
249 , genPrimopCodeBuilderArgs
250 , ghcBuilderArgs
251 , ghcPkgBuilderArgs
252 , haddockBuilderArgs
253 , happyBuilderArgs
254 , hsc2hsBuilderArgs
255 , hsCppBuilderArgs
256 , ldBuilderArgs
257 , makeBuilderArgs
258 , runTestBuilderArgs
259 , validateBuilderArgs
260 , xelatexBuilderArgs
261 -- Generic builders from the Hadrian library:
262 , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
263 , builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
264 , builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
265 , builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
266 , builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
267 , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
268 , builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
269
270 -- | All 'Package'-dependent command line arguments.
271 defaultPackageArgs :: Args
272 defaultPackageArgs = mconcat [ packageArgs
273 , builder Ghc ? ghcWarningsArgs ]