Commit bf70983e authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Decompose src/Settings/Builders/Gcc.hs, factor out cIncludeArgs into...

Decompose src/Settings/Builders/Gcc.hs, factor out cIncludeArgs into src/Settings/Builders/Common.hs.
parent 0c9571aa
......@@ -17,6 +17,7 @@ import Settings.Builders.Hsc2Hs
import Settings.Builders.HsCpp
import Settings.Builders.Ld
import Settings.Packages.Compiler
import Settings.Packages.Directory
import Settings.User
getArgs :: Expr [String]
......@@ -50,4 +51,5 @@ defaultBuilderArgs = mconcat
defaultPackageArgs :: Args
defaultPackageArgs = mconcat
[ compilerArgs ]
[ compilerArgs
, directoryArgs ]
module Settings.Builders.Common (includesArgs) where
module Settings.Builders.Common (includesArgs, cIncludeArgs) where
import Base
import Expression
import Oracles.PackageData
import Settings
includes :: [FilePath]
includes = [ "includes", "includes/dist-derivedconstants/header" ]
includesArgs :: Args
includesArgs = append $ map ("-I" ++) includes
cIncludeArgs :: Args
cIncludeArgs = do
stage <- getStage
pkg <- getPackage
incDirs <- getPkgDataList IncludeDirs
depDirs <- getPkgDataList DepIncludeDirs
let buildPath = targetPath stage pkg -/- "build"
mconcat [ arg $ "-I" ++ buildPath
, arg $ "-I" ++ buildPath -/- "autogen"
, append [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
, append [ "-I" ++ dir | dir <- depDirs ] ]
......@@ -2,20 +2,14 @@ module Settings.Builders.Gcc (gccArgs, gccMArgs) where
import Development.Shake.FilePath
import Expression
import GHC
import Oracles
import Base ((-/-))
import Predicates (package, stagedBuilder)
import Predicates (stagedBuilder)
import Settings
import Settings.Builders.Common (cIncludeArgs)
-- TODO: I had to define symbol __GLASGOW_HASKELL__ as otherwise directory.c is
-- effectively empty. I presume it was expected that GHC will be used for
-- compiling all C files, but I don't know why. It seems that directory.c is the
-- only file which requires special treatment when using GCC.
gccArgs :: Args
gccArgs = stagedBuilder Gcc ?
mconcat [ commonGccArgs
, package directory ? arg "-D__GLASGOW_HASKELL__"
, arg "-c", arg =<< getInput
, arg "-o", arg =<< getOutput ]
......@@ -35,12 +29,5 @@ gccMArgs = stagedBuilder GccM ? do
, arg =<< getInput ]
commonGccArgs :: Args
commonGccArgs = do
pkg <- getPackage
path <- getTargetPath
iDirs <- getPkgDataList IncludeDirs
dDirs <- getPkgDataList DepIncludeDirs
ccArgs <- getPkgDataList CcArgs
mconcat [ append ccArgs
, arg $ "-I" ++ path -/- "build/autogen"
, append [ "-I" ++ pkgPath pkg -/- dir | dir <- iDirs ++ dDirs ]]
commonGccArgs = mconcat [ append =<< getPkgDataList CcArgs
, cIncludeArgs ]
......@@ -7,6 +7,7 @@ import GHC
import Predicates hiding (way, stage)
import Settings
import Settings.Builders.GhcCabal (bootPackageDbArgs)
import Settings.Builders.Common (cIncludeArgs)
-- TODO: add support for -dyno
-- $1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.hs-boot
......@@ -114,16 +115,13 @@ includeGhcArgs = do
pkg <- getPackage
path <- getTargetPath
srcDirs <- getPkgDataList SrcDirs
incDirs <- getPkgDataList IncludeDirs
let buildPath = path -/- "build"
autogenPath = buildPath -/- "autogen"
mconcat [ arg "-i"
, arg $ "-i" ++ buildPath
, arg $ "-i" ++ autogenPath
, arg $ "-I" ++ buildPath
, arg $ "-I" ++ autogenPath
, append [ "-i" ++ pkgPath pkg -/- dir | dir <- srcDirs ]
, append [ "-I" ++ pkgPath pkg -/- dir | dir <- incDirs ]
, cIncludeArgs
, (pkg == compiler || pkg == ghc) ?
arg ("-I" ++ pkgPath compiler -/- "stage" ++ show (fromEnum stage))
, not (pkg == hp2ps || pkg == ghcCabal && stage == Stage0) ?
......
......@@ -9,6 +9,7 @@ import Oracles
import Predicates (builder, stage0, notStage0)
import Settings
import Settings.Builders.GhcCabal hiding (cppArgs)
import Settings.Builders.Common (cIncludeArgs)
templateHsc :: FilePath
templateHsc = "inplace/lib/template-hsc.h"
......@@ -48,18 +49,14 @@ hsc2HsArgs = builder Hsc2Hs ? do
getCFlags :: Expr [String]
getCFlags = fromDiffExpr $ do
pkg <- getPackage
path <- getTargetPath
iDirs <- getPkgDataList IncludeDirs
dDirs <- getPkgDataList DepIncludeDirs
cppArgs <- getPkgDataList CppArgs
depCcArgs <- getPkgDataList DepCcArgs
mconcat [ ccArgs
, argStagedSettingList ConfCcArgs
, remove ["-O"]
, argStagedSettingList ConfCppArgs
, arg $ "-I" ++ path -/- "build/autogen"
, append [ "-I" ++ pkgPath pkg -/- dir | dir <- iDirs ++ dDirs ]
, cIncludeArgs
, append cppArgs
, append depCcArgs
, ccWarnings
......
module Settings.Packages.Directory (directoryArgs) where
import Expression
import GHC (directory)
import Predicates (stagedBuilder, package)
-- TODO: I had to define symbol __GLASGOW_HASKELL__ as otherwise directory.c is
-- effectively empty. I presume it was expected that GHC will be used for
-- compiling all C files, but I don't know why. It seems that directory.c is the
-- only file which requires special treatment when using GCC.
directoryArgs :: Args
directoryArgs = package directory ?
stagedBuilder Gcc ? arg "-D__GLASGOW_HASKELL__"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment