1900ff151d5f3be2afc2177697eaabcc93c60389
[hadrian.git] / src / Settings / Builders / Gcc.hs
1 module Settings.Builders.Gcc (gccArgs, gccMArgs) where
2
3 import Expression
4 import Predicates (stagedBuilder)
5 import Oracles.PackageData
6 import Settings.Util
7
8 -- TODO: check code duplication
9 gccArgs :: Args
10 gccArgs = stagedBuilder Gcc ? do
11 file <- getFile
12 src <- getSource
13 ccArgs <- getPkgDataList CcArgs
14 mconcat [ append ccArgs
15 , includeGccArgs
16 , arg "-c"
17 , arg src
18 , arg "-o"
19 , arg file ]
20
21 -- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
22 gccMArgs :: Args
23 gccMArgs = stagedBuilder GccM ? do
24 file <- getFile
25 src <- getSource
26 ccArgs <- getPkgDataList CcArgs
27 mconcat [ arg "-E"
28 , arg "-MM"
29 , append ccArgs -- TODO: remove? any other flags?
30 , includeGccArgs
31 , arg "-MF"
32 , arg file
33 , arg "-MT"
34 , arg $ dropExtension file -<.> "o"
35 , arg "-x"
36 , arg "c"
37 , arg src ]
38
39 includeGccArgs :: Args
40 includeGccArgs = do
41 pkg <- getPackage
42 path <- getTargetPath
43 iDirs <- getPkgDataList IncludeDirs
44 dDirs <- getPkgDataList DepIncludeDirs
45 mconcat
46 [ arg $ "-I" ++ path -/- "build/autogen"
47 , append . map (\dir -> "-I" ++ pkgPath pkg -/- dir) $ iDirs ++ dDirs ]