Remove `parallel` as a submodule
[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, getPackageByPath,
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 getPackageByPath :: FilePath -> Action Package
143 getPackageByPath pkgpath = do
144 case filter (\p -> pkgPath p == pkgpath) knownPackages of
145 (p:_) -> return p
146 _ -> error $
147 "getPackageByPath: couldn't find a package with path: " ++ pkgpath
148
149 -- | Default build ways for library packages:
150 -- * We always build 'vanilla' way.
151 -- * We build 'profiling' way when stage > Stage0.
152 -- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
153 defaultLibraryWays :: Ways
154 defaultLibraryWays = mconcat
155 [ pure [vanilla]
156 , notStage0 ? pure [profiling]
157 , notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
158 ]
159
160 -- | Default build ways for the RTS.
161 defaultRtsWays :: Ways
162 defaultRtsWays = mconcat
163 [ pure [vanilla, threaded]
164 , notStage0 ? pure
165 [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling
166 , logging, threadedLogging
167 , debug, threadedDebug
168 ]
169 , notStage0 ? platformSupportsSharedLibs ? pure
170 [ dynamic, threadedDynamic, debugDynamic, loggingDynamic
171 , threadedDebugDynamic, threadedLoggingDynamic
172 ]
173 ]
174
175 -- TODO: Move C source arguments here
176 -- | Default and package-specific source arguments.
177 data SourceArgs = SourceArgs
178 { hsDefault :: Args
179 , hsLibrary :: Args
180 , hsCompiler :: Args
181 , hsGhc :: Args }
182
183 -- | Concatenate source arguments in appropriate order.
184 sourceArgs :: SourceArgs -> Args
185 sourceArgs SourceArgs {..} = builder Ghc ? mconcat
186 [ hsDefault
187 , getContextData hcOpts
188 , libraryPackage ? hsLibrary
189 , package compiler ? hsCompiler
190 , package ghc ? hsGhc ]
191
192 -- | All default command line arguments.
193 defaultArgs :: Args
194 defaultArgs = mconcat
195 [ defaultBuilderArgs
196 , sourceArgs defaultSourceArgs
197 , defaultPackageArgs ]
198
199 -- | Default source arguments, e.g. optimisation settings.
200 defaultSourceArgs :: SourceArgs
201 defaultSourceArgs = SourceArgs
202 { hsDefault = mconcat [ stage0 ? arg "-O"
203 , notStage0 ? arg "-O2"
204 , arg "-H32m" ]
205 , hsLibrary = mempty
206 , hsCompiler = mempty
207 , hsGhc = mempty }
208
209 -- Please update doc/flavours.md when changing the default build flavour.
210 -- | Default build flavour. Other build flavours are defined in modules
211 -- @Settings.Flavours.*@. Users can add new build flavours in "UserSettings".
212 defaultFlavour :: Flavour
213 defaultFlavour = Flavour
214 { name = "default"
215 , args = defaultArgs
216 , packages = defaultPackages
217 , integerLibrary = (\x -> if x then integerSimple else integerGmp) <$> cmdIntegerSimple
218 , libraryWays = defaultLibraryWays
219 , rtsWays = defaultRtsWays
220 , splitObjects = defaultSplitObjects
221 , dynamicGhcPrograms = defaultDynamicGhcPrograms
222 , ghciWithDebugger = False
223 , ghcProfiled = False
224 , ghcDebugged = False }
225
226 -- | Default logic for determining whether to build
227 -- dynamic GHC programs.
228 --
229 -- It corresponds to the DYNAMIC_GHC_PROGRAMS logic implemented
230 -- in @mk/config.mk.in@.
231 defaultDynamicGhcPrograms :: Action Bool
232 defaultDynamicGhcPrograms = do
233 win <- windowsHost
234 supportsShared <- platformSupportsSharedLibs
235 return (not win && supportsShared)
236
237 -- | Default condition for building split objects.
238 defaultSplitObjects :: Predicate
239 defaultSplitObjects = do
240 goodStage <- notStage0 -- We don't split bootstrap (stage 0) packages
241 pkg <- getPackage
242 supported <- expr supportsSplitObjects
243 split <- expr cmdSplitObjects
244 let goodPackage = isLibrary pkg && pkg /= compiler && pkg /= rts
245 return $ split && goodStage && goodPackage && supported
246
247 -- | All 'Builder'-dependent command line arguments.
248 defaultBuilderArgs :: Args
249 defaultBuilderArgs = mconcat
250 -- GHC-specific builders:
251 [ alexBuilderArgs
252 , cabalBuilderArgs
253 , ccBuilderArgs
254 , configureBuilderArgs
255 , deriveConstantsBuilderArgs
256 , genPrimopCodeBuilderArgs
257 , ghcBuilderArgs
258 , ghcPkgBuilderArgs
259 , haddockBuilderArgs
260 , happyBuilderArgs
261 , hsc2hsBuilderArgs
262 , hsCppBuilderArgs
263 , ldBuilderArgs
264 , makeBuilderArgs
265 , runTestBuilderArgs
266 , validateBuilderArgs
267 , xelatexBuilderArgs
268 -- Generic builders from the Hadrian library:
269 , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
270 , builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
271 , builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
272 , builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
273 , builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
274 , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
275 , builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
276
277 -- | All 'Package'-dependent command line arguments.
278 defaultPackageArgs :: Args
279 defaultPackageArgs = mconcat [ packageArgs
280 , builder Ghc ? ghcWarningsArgs ]