Fix warnings (#547)
[hadrian.git] / src / Settings / Builders / Common.hs
1 module Settings.Builders.Common (
2 module Base,
3 module Expression,
4 module Oracles.Flag,
5 module Oracles.Setting,
6 module Settings,
7 module UserSettings,
8 cIncludeArgs, ldArgs, cArgs, cWarnings,
9 packageDatabaseArgs, bootPackageDatabaseArgs
10 ) where
11
12 import Base
13 import Expression
14 import GHC.Packages
15 import Hadrian.Haskell.Cabal.PackageData as PD
16 import Oracles.Flag
17 import Oracles.Setting
18 import Settings
19 import UserSettings
20
21 cIncludeArgs :: Args
22 cIncludeArgs = do
23 pkg <- getPackage
24 root <- getBuildRoot
25 path <- getBuildPath
26 incDirs <- getPackageData PD.includeDirs
27 depDirs <- getPackageData PD.depIncludeDirs
28 iconvIncludeDir <- getSetting IconvIncludeDir
29 gmpIncludeDir <- getSetting GmpIncludeDir
30 ffiIncludeDir <- getSetting FfiIncludeDir
31
32 cross <- expr crossCompiling
33 compilerOrGhc <- package compiler ||^ package ghc
34 mconcat [ not (cross && compilerOrGhc) ? arg "-Iincludes"
35 , arg $ "-I" ++ root -/- generatedDir
36 , arg $ "-I" ++ path
37 , pure . map ("-I"++) . filter (/= "") $ [iconvIncludeDir, gmpIncludeDir]
38 , flag UseSystemFfi ? arg ("-I" ++ ffiIncludeDir)
39 -- add the build path with include dirs in case we generated
40 -- some files with autoconf, which will end up in the build directory.
41 , pure [ "-I" ++ path -/- dir | dir <- incDirs ]
42 -- add the package directory with include dirs, for includes
43 -- shipped with the package
44 , pure [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
45 , pure [ "-I" ++ unifyPath dir | dir <- depDirs ] ]
46
47 ldArgs :: Args
48 ldArgs = mempty
49
50 cArgs :: Args
51 cArgs = mempty
52
53 -- TODO: should be in a different file
54 cWarnings :: Args
55 cWarnings = mconcat
56 [ arg "-Wall"
57 , flag GccIsClang ? arg "-Wno-unknown-pragmas"
58 , notM (flag GccIsClang) ? notM windowsHost ? arg "-Werror=unused-but-set-variable"
59 , notM (flag GccIsClang) ? arg "-Wno-error=inline" ]
60
61 packageDatabaseArgs :: Args
62 packageDatabaseArgs = do
63 stage <- getStage
64 dbPath <- expr (packageDbPath stage)
65 expr (need [dbPath -/- packageDbStamp])
66 root <- getBuildRoot
67 prefix <- ifM (builder Ghc) (return "-package-db ") (return "--package-db=")
68 arg $ prefix ++ root -/- relativePackageDbPath stage
69
70 bootPackageDatabaseArgs :: Args
71 bootPackageDatabaseArgs = do
72 stage <- getStage
73 dbPath <- expr $ packageDbPath stage
74 expr $ need [dbPath -/- packageDbStamp]
75 stage0 ? packageDatabaseArgs