[commit: ghc] wip/nfs-locking: Decompose src/Settings/Builders/Gcc.hs, factor out cIncludeArgs into src/Settings/Builders/Common.hs. (bf70983)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:49:48 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/bf70983e38c76138bf5819a2dff9109181a1f2aa/ghc
>---------------------------------------------------------------
commit bf70983e38c76138bf5819a2dff9109181a1f2aa
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Tue Dec 29 21:46:04 2015 +0000
Decompose src/Settings/Builders/Gcc.hs, factor out cIncludeArgs into src/Settings/Builders/Common.hs.
>---------------------------------------------------------------
bf70983e38c76138bf5819a2dff9109181a1f2aa
src/Settings/Args.hs | 4 +++-
src/Settings/Builders/Common.hs | 17 ++++++++++++++++-
src/Settings/Builders/Gcc.hs | 21 ++++-----------------
src/Settings/Builders/Ghc.hs | 6 ++----
src/Settings/Builders/Hsc2Hs.hs | 7 ++-----
src/Settings/Packages/Directory.hs | 13 +++++++++++++
6 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/src/Settings/Args.hs b/src/Settings/Args.hs
index 6715680..f474f8f 100644
--- a/src/Settings/Args.hs
+++ b/src/Settings/Args.hs
@@ -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 ]
diff --git a/src/Settings/Builders/Common.hs b/src/Settings/Builders/Common.hs
index fc3ed53..9ed6efd 100644
--- a/src/Settings/Builders/Common.hs
+++ b/src/Settings/Builders/Common.hs
@@ -1,9 +1,24 @@
-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 ] ]
diff --git a/src/Settings/Builders/Gcc.hs b/src/Settings/Builders/Gcc.hs
index fab5104..8a6b087 100644
--- a/src/Settings/Builders/Gcc.hs
+++ b/src/Settings/Builders/Gcc.hs
@@ -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 ]
diff --git a/src/Settings/Builders/Ghc.hs b/src/Settings/Builders/Ghc.hs
index f354458..593f0e0 100644
--- a/src/Settings/Builders/Ghc.hs
+++ b/src/Settings/Builders/Ghc.hs
@@ -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) ?
diff --git a/src/Settings/Builders/Hsc2Hs.hs b/src/Settings/Builders/Hsc2Hs.hs
index 90abc82..c89caf0 100644
--- a/src/Settings/Builders/Hsc2Hs.hs
+++ b/src/Settings/Builders/Hsc2Hs.hs
@@ -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
diff --git a/src/Settings/Packages/Directory.hs b/src/Settings/Packages/Directory.hs
new file mode 100644
index 0000000..3ff69ce
--- /dev/null
+++ b/src/Settings/Packages/Directory.hs
@@ -0,0 +1,13 @@
+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__"
More information about the ghc-commits
mailing list