Gcc.hs 1.33 KB
Newer Older
1
module Settings.Builders.Gcc (gccArgs, gccMArgs) where
2 3 4 5 6 7 8 9

import Base
import Util
import Builder
import Expression
import Oracles.PackageData
import Settings.Util

10
-- TODO: check code duplication
11 12 13 14
gccArgs :: Args
gccArgs = stagedBuilder Gcc ? do
    path   <- getTargetPath
    file   <- getFile
Andrey Mokhov's avatar
Andrey Mokhov committed
15
    src    <- getSource
16 17 18 19
    ccArgs <- getPkgDataList CcArgs
    mconcat [ append ccArgs
            , includeGccArgs
            , arg "-c"
Andrey Mokhov's avatar
Andrey Mokhov committed
20
            , arg src
21 22 23
            , arg "-o"
            , arg file ]

24 25 26 27 28
-- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
gccMArgs :: Args
gccMArgs = stagedBuilder GccM ? do
    path   <- getTargetPath
    file   <- getFile
Andrey Mokhov's avatar
Andrey Mokhov committed
29
    src    <- getSource
30 31 32 33 34 35 36 37
    ccArgs <- getPkgDataList CcArgs
    mconcat
        [ arg "-E"
        , arg "-MM"
        , append ccArgs -- TODO: remove? any other flags?
        , includeGccArgs
        , arg "-MF"
        , arg file
Andrey Mokhov's avatar
Andrey Mokhov committed
38 39
        , arg "-MT"
        , arg $ dropExtension file -<.> "o"
40 41 42 43
        , arg "-x"
        , arg "c"
        , arg src ]

44 45 46 47 48 49 50 51 52 53
includeGccArgs :: Args
includeGccArgs = do
    path    <- getTargetPath
    pkgPath <- getPackagePath
    pkg     <- getPackage
    iDirs   <- getPkgDataList IncludeDirs
    dDirs   <- getPkgDataList DepIncludeDirs
    mconcat
        [ arg $ "-I" ++ path -/- "build/autogen"
        , append . map (\dir -> "-I" ++ pkgPath -/- dir) $ iDirs ++ dDirs ]