[commit: ghc] wip/nfs-locking: Generate includes/ghcversion.h (66f18be)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:31:15 UTC 2017


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

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

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

commit 66f18bec2737a73fc1b2387726e22a35ef6edd8a
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Sun Dec 27 14:27:55 2015 +0800

    Generate includes/ghcversion.h
    
    This should be the final commit to fix #39.


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

66f18bec2737a73fc1b2387726e22a35ef6edd8a
 shaking-up-ghc.cabal                |  1 +
 src/Rules/Generate.hs               |  2 ++
 src/Rules/Generators/GhcVersionH.hs | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/shaking-up-ghc.cabal b/shaking-up-ghc.cabal
index 941651b..0e60637 100644
--- a/shaking-up-ghc.cabal
+++ b/shaking-up-ghc.cabal
@@ -46,6 +46,7 @@ executable ghc-shake
                        , Rules.Generators.GhcAutoconfH
                        , Rules.Generators.GhcBootPlatformH
                        , Rules.Generators.GhcPlatformH
+                       , Rules.Generators.GhcVersionH
                        , Rules.Generators.VersionHs
                        , Rules.Install
                        , Rules.Library
diff --git a/src/Rules/Generate.hs b/src/Rules/Generate.hs
index ccd059f..bc0089c 100644
--- a/src/Rules/Generate.hs
+++ b/src/Rules/Generate.hs
@@ -9,6 +9,7 @@ import Rules.Generators.ConfigHs
 import Rules.Generators.GhcAutoconfH
 import Rules.Generators.GhcBootPlatformH
 import Rules.Generators.GhcPlatformH
+import Rules.Generators.GhcVersionH
 import Rules.Generators.VersionHs
 import Oracles.ModuleFiles
 import Rules.Actions
@@ -107,6 +108,7 @@ generateRules :: Rules ()
 generateRules = do
     "includes/ghcautoconf.h" <~ generateGhcAutoconfH
     "includes/ghcplatform.h" <~ generateGhcPlatformH
+    "includes/ghcversion.h"  <~ generateGhcVersionH
   where
     file <~ gen = file %> \out -> generate out emptyTarget gen
 
diff --git a/src/Rules/Generators/GhcVersionH.hs b/src/Rules/Generators/GhcVersionH.hs
new file mode 100644
index 0000000..a45df55
--- /dev/null
+++ b/src/Rules/Generators/GhcVersionH.hs
@@ -0,0 +1,33 @@
+module Rules.Generators.GhcVersionH (generateGhcVersionH) where
+
+import Expression
+import Oracles
+
+generateGhcVersionH :: Expr String
+generateGhcVersionH = do
+    version     <- getSetting ProjectVersionInt
+    patchLevel1 <- getSetting ProjectPatchLevel1
+    patchLevel2 <- getSetting ProjectPatchLevel2
+    return . unlines $
+        [ "#ifndef __GHCVERSION_H__"
+        , "#define __GHCVERSION_H__"
+        , ""
+        , "#ifndef __GLASGOW_HASKELL__"
+        , "# define __GLASGOW_HASKELL__ " ++ version
+        , "#endif"
+        , ""]
+        ++
+        [ "#define __GLASGOW_HASKELL_PATCHLEVEL1__ " ++ patchLevel1 | patchLevel1 /= "" ]
+        ++
+        [ "#define __GLASGOW_HASKELL_PATCHLEVEL2__ " ++ patchLevel2 | patchLevel2 /= "" ]
+        ++
+        [ ""
+        , "#define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) (\\"
+        , "   ((ma)*100+(mi)) <  __GLASGOW_HASKELL__ || \\"
+        , "   ((ma)*100+(mi)) == __GLASGOW_HASKELL__    \\"
+        , "          && (pl1) <  __GLASGOW_HASKELL_PATCHLEVEL1__ || \\"
+        , "   ((ma)*100+(mi)) == __GLASGOW_HASKELL__    \\"
+        , "          && (pl1) == __GLASGOW_HASKELL_PATCHLEVEL1__ \\"
+        , "          && (pl2) <= __GLASGOW_HASKELL_PATCHLEVEL2__ )"
+        , ""
+        , "#endif /* __GHCVERSION_H__ */" ]



More information about the ghc-commits mailing list