[commit: ghc] wip/nfs-locking: Implement build rule for template-hsc.h, fix #44. (6863e5e)

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


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

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

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

commit 6863e5e13c4182976f330a14696109504d1e59b2
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sat Dec 26 18:31:46 2015 +0000

    Implement build rule for template-hsc.h, fix #44.


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

6863e5e13c4182976f330a14696109504d1e59b2
 shaking-up-ghc.cabal            |  1 +
 src/Main.hs                     |  2 ++
 src/Rules/Install.hs            | 11 +++++++++++
 src/Settings/Builders/Hsc2Hs.hs |  6 +++++-
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/shaking-up-ghc.cabal b/shaking-up-ghc.cabal
index 1e0fbbf..941651b 100644
--- a/shaking-up-ghc.cabal
+++ b/shaking-up-ghc.cabal
@@ -47,6 +47,7 @@ executable ghc-shake
                        , Rules.Generators.GhcBootPlatformH
                        , Rules.Generators.GhcPlatformH
                        , Rules.Generators.VersionHs
+                       , Rules.Install
                        , Rules.Library
                        , Rules.Oracles
                        , Rules.Package
diff --git a/src/Main.hs b/src/Main.hs
index 0dc8d96..fdc43cd 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -3,12 +3,14 @@ import Rules
 import Rules.Cabal
 import Rules.Config
 import Rules.Generate
+import Rules.Install
 import Rules.Oracles
 
 main :: IO ()
 main = shakeArgs options $ do
     cabalRules      -- see Rules.Cabal
     configRules     -- see Rules.Config
+    installRules    -- see Rules.Install
     generateTargets -- see Rules
     generateRules   -- see Rules.Generate
     oracleRules     -- see Rules.Oracles
diff --git a/src/Rules/Install.hs b/src/Rules/Install.hs
new file mode 100644
index 0000000..b592728
--- /dev/null
+++ b/src/Rules/Install.hs
@@ -0,0 +1,11 @@
+module Rules.Install (installRules) where
+
+import Expression
+import GHC
+
+installRules :: Rules ()
+installRules = do
+    "inplace/lib/template-hsc.h" %> \out -> do
+        let source = pkgPath hsc2hs -/- "template-hsc.h"
+        putBuild $ "| Copying " ++ source ++ " -> " ++ out
+        copyFileChanged source out
diff --git a/src/Settings/Builders/Hsc2Hs.hs b/src/Settings/Builders/Hsc2Hs.hs
index 0c6172d..6721aaf 100644
--- a/src/Settings/Builders/Hsc2Hs.hs
+++ b/src/Settings/Builders/Hsc2Hs.hs
@@ -6,6 +6,9 @@ import Predicates (builder, stage0, notStage0)
 import Settings
 import Settings.Builders.GhcCabal hiding (cppArgs)
 
+templateHsc :: FilePath
+templateHsc = "inplace/lib/template-hsc.h"
+
 hsc2HsArgs :: Args
 hsc2HsArgs = builder Hsc2Hs ? do
     stage   <- getStage
@@ -21,6 +24,7 @@ hsc2HsArgs = builder Hsc2Hs ? do
     version <- if stage == Stage0
                then lift $ ghcCanonVersion
                else getSetting ProjectVersionInt
+    lift $ need [templateHsc]
     mconcat [ arg $ "--cc=" ++ ccPath
             , arg $ "--ld=" ++ ccPath
             , notM windowsHost ? arg "--cross-safe"
@@ -33,7 +37,7 @@ hsc2HsArgs = builder Hsc2Hs ? do
             , notStage0 ? arg ("--cflag=-D" ++ tArch ++ "_HOST_ARCH=1")
             , notStage0 ? arg ("--cflag=-D" ++ tOs   ++ "_HOST_OS=1"  )
             , arg ("--cflag=-D__GLASGOW_HASKELL__=" ++ version)
-            , arg $ "--template=" ++ top -/- "inplace/lib/template-hsc.h"
+            , arg $ "--template=" ++ top -/- templateHsc
             , arg $ "-I" ++ top -/- "inplace/lib/include/"
             , arg =<< getInput
             , arg "-o", arg =<< getOutput ]



More information about the ghc-commits mailing list