[commit: ghc] wip/nfs-locking: Collect arguments for Hsc2Hs builder. (f225aed)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:37:30 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/f225aedc18efa02b48f99ee84d0794eb4aa94368/ghc

>---------------------------------------------------------------

commit f225aedc18efa02b48f99ee84d0794eb4aa94368
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Mon Sep 21 00:54:29 2015 +0100

    Collect arguments for Hsc2Hs builder.


>---------------------------------------------------------------

f225aedc18efa02b48f99ee84d0794eb4aa94368
 src/Settings/Builders/Hsc2Hs.hs | 70 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/src/Settings/Builders/Hsc2Hs.hs b/src/Settings/Builders/Hsc2Hs.hs
new file mode 100644
index 0000000..fae7c1f
--- /dev/null
+++ b/src/Settings/Builders/Hsc2Hs.hs
@@ -0,0 +1,70 @@
+module Settings.Builders.Hsc2Hs (hsc2HsArgs) where
+
+import Expression
+import Oracles
+import Predicates (builder, stage0, notStage0)
+import Settings
+import Settings.Builders.GhcCabal
+
+hsc2HsArgs :: Args
+hsc2HsArgs = builder Hsc2Hs ? do
+    stage   <- getStage
+    src     <- getSource
+    file    <- getFile
+    ccPath  <- lift . builderPath $ Gcc stage
+    gmpDirs <- getSettingList GmpIncludeDirs
+    cFlags  <- getCFlags
+    lFlags  <- getLFlags
+    hArch   <- getSetting HostArch
+    hOs     <- getSetting HostOs
+    tArch   <- getSetting TargetArch
+    tOs     <- getSetting TargetOs
+    version <- if stage == Stage0
+               then lift $ ghcCanonVersion
+               else getSetting ProjectVersionInt
+    mconcat [ arg $ "--cc=" ++ ccPath
+            , arg $ "--ld=" ++ ccPath
+            , notWindowsHost ? arg "--cross-safe"
+            , append $ map ("-I"       ++) gmpDirs
+            , append $ map ("--cflag=" ++) cFlags
+            , append $ map ("--lflag=" ++) lFlags
+            , notStage0 ? crossCompiling ? arg "--cross-compile"
+            , stage0    ? arg ("--cflag=-D" ++ hArch ++ "_HOST_ARCH=1")
+            , stage0    ? arg ("--cflag=-D" ++ hOs   ++ "_HOST_OS=1"  )
+            , notStage0 ? arg ("--cflag=-D" ++ tArch ++ "_HOST_ARCH=1")
+            , notStage0 ? arg ("--cflag=-D" ++ tOs   ++ "_HOST_OS=1"  )
+            , arg ("--cflag=-D__GLASGOW_HASKELL__=" ++ version)
+            , arg src
+            , arg "-o", arg file ]
+
+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 ]
+            , append cppArgs
+            , append depCcArgs
+            , ccWarnings
+            , arg "-include", arg $ path -/- "build/autogen/cabal_macros.h" ]
+
+getLFlags :: Expr [String]
+getLFlags = fromDiffExpr $ do
+    ldArgs    <- getPkgDataList LdArgs
+    libDirs   <- getPkgDataList DepLibDirs
+    extraLibs <- getPkgDataList DepExtraLibs
+    depLdArgs <- getPkgDataList DepLdArgs
+    mconcat [ argStagedSettingList ConfGccLinkerArgs
+            --, ldArgs -- TODO: resolve name conflict (ldArgs is currently empty)
+            , append ldArgs
+            , append $ [ "-L" ++ unifyPath dir | dir <- libDirs ]
+            , append $ [ "-l" ++ unifyPath dir | dir <- extraLibs ]
+            , append depLdArgs ]



More information about the ghc-commits mailing list