[commit: ghc] wip/nfs-locking: Add generator for ghc-pkg//Version.hs. (3021dbe)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:10:34 UTC 2017


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

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

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

commit 3021dbebbbc22acc67880f62a067417dcc9b486b
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sat Dec 12 00:41:26 2015 +0000

    Add generator for ghc-pkg//Version.hs.


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

3021dbebbbc22acc67880f62a067417dcc9b486b
 src/Rules/Generate.hs | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/Rules/Generate.hs b/src/Rules/Generate.hs
index 6f45dbd..97fb81f 100644
--- a/src/Rules/Generate.hs
+++ b/src/Rules/Generate.hs
@@ -4,7 +4,7 @@ import Expression
 import GHC
 import Oracles
 import Rules.Actions
-import Rules.Resources
+import Rules.Resources (Resources)
 import Settings
 
 primopsSource :: FilePath
@@ -65,6 +65,12 @@ generatePackageCode _ target @ (PartialTarget stage pkg) =
             writeFileChanged file contents
             putBuild $ "| Successfully generated '" ++ file ++ "'."
 
+        priority 2.0 $
+            when (pkg == ghcPkg) $ buildPath -/- "Version.hs" %> \file -> do
+                contents <- interpretPartial target generateGhcPkgVersionHs
+                writeFileChanged file contents
+                putBuild $ "| Successfully generated '" ++ file ++ "'."
+
 quote :: String -> String
 quote s = "\"" ++ s ++ "\""
 
@@ -211,3 +217,15 @@ generatePlatformH = do
         , "#define TARGET_VENDOR " ++ quote targetVendor
         , ""
         , "#endif /* __PLATFORM_H__ */" ]
+
+generateGhcPkgVersionHs :: Expr String
+generateGhcPkgVersionHs = do
+    projectVersion <- getSetting ProjectVersion
+    targetOs       <- getSetting TargetOs
+    targetArch     <- getSetting TargetArch
+    return $ unlines
+        [ "module Version where"
+        , "version, targetOS, targetARCH :: String"
+        , "version    = " ++ quote projectVersion
+        , "targetOS   = " ++ quote targetOs
+        , "targetARCH = " ++ quote targetArch ]



More information about the ghc-commits mailing list