[Git][ghc/ghc][master] Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version
Marge Bot
gitlab at gitlab.haskell.org
Fri Jul 3 21:34:41 UTC 2020
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00
Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version
- - - - -
6 changed files:
- docs/users_guide/phases.rst
- hadrian/src/Rules/Generate.hs
- includes/ghc.mk
- + testsuite/tests/driver/FullGHCVersion.hs
- + testsuite/tests/driver/FullGHCVersion.stdout
- testsuite/tests/driver/all.T
Changes:
=====================================
docs/users_guide/phases.rst
=====================================
@@ -332,6 +332,13 @@ defined by your local GHC installation, the following trick is useful:
source, including the C source generated from a Haskell module (i.e.
``.hs``, ``.lhs``, ``.c`` and ``.hc`` files).
+``__GLASGOW_HASKELL_FULL_VERSION__``
+ .. index::
+ single: __GLASGOW_HASKELL_FULL_VERSION__
+ This macro exposes the full version string.
+ For instance: ``__FULL_GHC_VERSION__==8.11.0.20200319``.
+ Its value comes from the ``ProjectVersion`` Autotools variable.
+
``__GLASGOW_HASKELL_PATCHLEVEL1__``; \ ``__GLASGOW_HASKELL_PATCHLEVEL2__``
.. index::
single: __GLASGOW_HASKELL_PATCHLEVEL2__
=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -398,6 +398,7 @@ generateGhcAutoconfH = do
generateGhcVersionH :: Expr String
generateGhcVersionH = do
trackGenerateHs
+ fullVersion <- getSetting ProjectVersion
version <- getSetting ProjectVersionInt
patchLevel1 <- getSetting ProjectPatchLevel1
patchLevel2 <- getSetting ProjectPatchLevel2
@@ -406,7 +407,10 @@ generateGhcVersionH = do
, "#define __GHCVERSION_H__"
, ""
, "#if !defined(__GLASGOW_HASKELL__)"
- , "# define __GLASGOW_HASKELL__ " ++ version
+ , "#define __GLASGOW_HASKELL__ " ++ version
+ , "#endif"
+ , "#if !defined(__GLASGOW_HASKELL_FULL_VERSION__)"
+ , "#define __GLASGOW_HASKELL_FULL_VERSION__ " ++ fullVersion
, "#endif"
, ""]
++
=====================================
includes/ghc.mk
=====================================
@@ -75,6 +75,7 @@ $$(includes_$1_H_VERSION) : mk/project.mk | $$$$(dir $$$$@)/.
@echo "#define __GHCVERSION_H__" >> $$@
@echo >> $$@
@echo "#define __GLASGOW_HASKELL__ $$(ProjectVersionInt)" >> $$@
+ @echo "#define __GLASGOW_HASKELL_FULL_VERSION__ $$(ProjectVersion)" >> $$@
@echo >> $$@
@if [ -n "$$(ProjectPatchLevel1)" ]; then \
echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ $$(ProjectPatchLevel1)" >> $$@; \
=====================================
testsuite/tests/driver/FullGHCVersion.hs
=====================================
@@ -0,0 +1,10 @@
+{-# LANGUAGE CPP #-}
+
+module Main where
+
+main :: IO ()
+#if defined(__GLASGOW_HASKELL_FULL_VERSION__)
+main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is well-defined!"
+#else
+main = putStrLn "__GLASGOW_HASKELL_FULL_VERSION__ is not defined!"
+#endif
=====================================
testsuite/tests/driver/FullGHCVersion.stdout
=====================================
@@ -0,0 +1 @@
+__GLASGOW_HASKELL_FULL_VERSION__ is well-defined!
=====================================
testsuite/tests/driver/all.T
=====================================
@@ -282,3 +282,4 @@ test('T16737',
test('T17143', exit_code(1), run_command, ['{compiler} T17143.hs -S -fno-code'])
test('T17786', unless(opsys('mingw32'), skip), makefile_test, [])
test('T18369', normal, compile, ['-O'])
+test('FullGHCVersion', normal, compile_and_run, ['-package ghc-boot'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7aa6ef110d8cc6626b1cf18d85a37cbac53e2795
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200703/7802b9bf/attachment-0001.html>
More information about the ghc-commits
mailing list