Drop append, simplify
[hadrian.git] / src / Settings / Builders / Common.hs
1 module Settings.Builders.Common (
2 module Base,
3 module Expression,
4 module GHC,
5 module Oracles.Config.Flag,
6 module Oracles.Config.Setting,
7 module Oracles.PackageData,
8 module Settings,
9 module Settings.Path,
10 module UserSettings,
11 cIncludeArgs, ldArgs, cArgs, cWarnings, bootPackageDatabaseArgs
12 ) where
13
14 import Base
15 import Expression
16 import GHC
17 import Oracles.Config.Flag
18 import Oracles.Config.Setting
19 import Oracles.PackageData
20 import Settings
21 import Settings.Path
22 import UserSettings
23
24 cIncludeArgs :: Args
25 cIncludeArgs = do
26 pkg <- getPackage
27 path <- getBuildPath
28 incDirs <- getPkgDataList IncludeDirs
29 depDirs <- getPkgDataList DepIncludeDirs
30 mconcat [ arg "-Iincludes"
31 , arg $ "-I" ++ generatedPath
32 , arg $ "-I" ++ path
33 , pure [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
34 , pure [ "-I" ++ unifyPath dir | dir <- depDirs ] ]
35
36 ldArgs :: Args
37 ldArgs = mempty
38
39 cArgs :: Args
40 cArgs = mempty
41
42 -- TODO: should be in a different file
43 cWarnings :: Args
44 cWarnings = do
45 let gccGe46 = notM $ (flag GccIsClang ||^ flag GccLt46)
46 mconcat [ arg "-Wall"
47 , flag GccIsClang ? arg "-Wno-unknown-pragmas"
48 , gccGe46 ? notM windowsHost ? arg "-Werror=unused-but-set-variable"
49 , gccGe46 ? arg "-Wno-error=inline" ]
50
51 bootPackageDatabaseArgs :: Args
52 bootPackageDatabaseArgs = do
53 stage <- getStage
54 expr $ need [packageDbStamp stage]
55 stage0 ? do
56 path <- expr topDirectory
57 prefix <- ifM (builder Ghc) (return "-package-db ") (return "--package-db=")
58 arg $ prefix ++ path -/- inplacePackageDbDirectory Stage0