031bd45ace3948b55a894bd5ba012dcaa97a1943
[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 ++ [ hpcBin | not cross ]
113 ++ [ iserv | not win, not cross ]
114 ++ [ libiserv | not win, not cross ]
115 ++ [ runGhc | not cross ]
116 ++ [ touchy | win ]
117 ++ [ unix | not win ]
118 ++ [ win32 | win ]
119
120 -- | Packages built in 'Stage2' by default. You can change this in "UserSettings".
121 stage2Packages :: Action [Package]
122 stage2Packages = do
123 cross <- flag CrossCompiling
124 return $ [ ghcTags ]
125 ++ [ haddock | not cross ]
126
127 -- | Packages that are built only for the testsuite.
128 testsuitePackages :: Action [Package]
129 testsuitePackages = do
130 win <- windowsHost
131 return $ [ checkApiAnnotations
132 , checkPpr
133 , ghci
134 , ghcCompact
135 , ghcPkg
136 , hp2ps
137 , hsc2hs
138 , iserv
139 , parallel
140 , runGhc
141 , unlit ] ++
142 [ timeout | win ]
143
144 -- | Default build ways for library packages:
145 -- * We always build 'vanilla' way.
146 -- * We build 'profiling' way when stage > Stage0.
147 -- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
148 defaultLibraryWays :: Ways
149 defaultLibraryWays = mconcat
150 [ pure [vanilla]
151 , notStage0 ? pure [profiling]
152 , notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
153 ]
154
155 -- | Default build ways for the RTS.
156 defaultRtsWays :: Ways
157 defaultRtsWays = mconcat
158 [ pure [vanilla, threaded]
159 , notStage0 ? pure
160 [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling
161 , logging, threadedLogging
162 , debug, threadedDebug
163 ]
164 , notStage0 ? platformSupportsSharedLibs ? pure
165 [ dynamic, threadedDynamic, debugDynamic, loggingDynamic
166 , threadedDebugDynamic, threadedLoggingDynamic
167 ]
168 ]
169
170 -- TODO: Move C source arguments here
171 -- | Default and package-specific source arguments.
172 data SourceArgs = SourceArgs
173 { hsDefault :: Args
174 , hsLibrary :: Args
175 , hsCompiler :: Args
176 , hsGhc :: Args }
177
178 -- | Concatenate source arguments in appropriate order.
179 sourceArgs :: SourceArgs -> Args
180 sourceArgs SourceArgs {..} = builder Ghc ? mconcat
181 [ hsDefault
182 , getContextData hcOpts
183 , libraryPackage ? hsLibrary
184 , package compiler ? hsCompiler
185 , package ghc ? hsGhc ]
186
187 -- | All default command line arguments.
188 defaultArgs :: Args
189 defaultArgs = mconcat
190 [ defaultBuilderArgs
191 , sourceArgs defaultSourceArgs
192 , defaultPackageArgs ]
193
194 -- | Default source arguments, e.g. optimisation settings.
195 defaultSourceArgs :: SourceArgs
196 defaultSourceArgs = SourceArgs
197 { hsDefault = mconcat [ stage0 ? arg "-O"
198 , notStage0 ? arg "-O2"
199 , arg "-H32m" ]
200 , hsLibrary = mempty
201 , hsCompiler = mempty
202 , hsGhc = mempty }
203
204 -- Please update doc/flavours.md when changing the default build flavour.
205 -- | Default build flavour. Other build flavours are defined in modules
206 -- @Settings.Flavours.*@. Users can add new build flavours in "UserSettings".
207 defaultFlavour :: Flavour
208 defaultFlavour = Flavour
209 { name = "default"
210 , args = defaultArgs
211 , packages = defaultPackages
212 , integerLibrary = (\x -> if x then integerSimple else integerGmp) <$> cmdIntegerSimple
213 , libraryWays = defaultLibraryWays
214 , rtsWays = defaultRtsWays
215 , splitObjects = defaultSplitObjects
216 , dynamicGhcPrograms = defaultDynamicGhcPrograms
217 , ghciWithDebugger = False
218 , ghcProfiled = False
219 , ghcDebugged = False }
220
221 -- | Default logic for determining whether to build
222 -- dynamic GHC programs.
223 --
224 -- It corresponds to the DYNAMIC_GHC_PROGRAMS logic implemented
225 -- in @mk/config.mk.in@.
226 defaultDynamicGhcPrograms :: Action Bool
227 defaultDynamicGhcPrograms = do
228 win <- windowsHost
229 supportsShared <- platformSupportsSharedLibs
230 return (not win && supportsShared)
231
232 -- | Default condition for building split objects.
233 defaultSplitObjects :: Predicate
234 defaultSplitObjects = do
235 goodStage <- notStage0 -- We don't split bootstrap (stage 0) packages
236 pkg <- getPackage
237 supported <- expr supportsSplitObjects
238 split <- expr cmdSplitObjects
239 let goodPackage = isLibrary pkg && pkg /= compiler && pkg /= rts
240 return $ split && goodStage && goodPackage && supported
241
242 -- | All 'Builder'-dependent command line arguments.
243 defaultBuilderArgs :: Args
244 defaultBuilderArgs = mconcat
245 -- GHC-specific builders:
246 [ alexBuilderArgs
247 , cabalBuilderArgs
248 , ccBuilderArgs
249 , configureBuilderArgs
250 , deriveConstantsBuilderArgs
251 , genPrimopCodeBuilderArgs
252 , ghcBuilderArgs
253 , ghcPkgBuilderArgs
254 , haddockBuilderArgs
255 , happyBuilderArgs
256 , hsc2hsBuilderArgs
257 , hsCppBuilderArgs
258 , ldBuilderArgs
259 , makeBuilderArgs
260 , runTestBuilderArgs
261 , validateBuilderArgs
262 , xelatexBuilderArgs
263 -- Generic builders from the Hadrian library:
264 , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
265 , builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
266 , builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
267 , builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
268 , builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
269 , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
270 , builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
271
272 -- | All 'Package'-dependent command line arguments.
273 defaultPackageArgs :: Args
274 defaultPackageArgs = mconcat [ packageArgs, warningArgs ]