From e2a7d8bb4565c061c853fbc9f73ffe5c28e6d060 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 27 Dec 2012 16:23:42 +0100 Subject: [PATCH] Include the git commit SHA1 in the version number. For bug reports it's very convenient to know the exact version. For release builds, the standard version triplet (major.minor.micro) is more than sufficient, but that's not the case for development builds. Due to the post-release version increment, development builds already have a version number that is distinct from previous releases, but including the git commit SHA1 is even more accurate. On Windows, the git commit SHA1 is also embedded in the version resource. --- configure.ac | 5 +++++ src/Makefile.am | 2 ++ src/libdivecomputer.rc.in | 17 ++++++++++++++++- src/version.c | 12 ++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cc8bda1..2fae4eb 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,11 @@ AC_SUBST([DC_VERSION_MINOR],[dc_version_minor]) AC_SUBST([DC_VERSION_MICRO],[dc_version_micro]) AC_SUBST([DC_VERSION_LIBTOOL],[dc_version_lt_current:dc_version_lt_revision:dc_version_lt_age]) +# Version suffix. +m4_ifset([dc_version_suffix],[ + AC_DEFINE(HAVE_VERSION_SUFFIX, [1], [Define if a version suffix is present.]) +]) + AC_CONFIG_FILES([ libdivecomputer.pc Makefile diff --git a/src/Makefile.am b/src/Makefile.am index fc5e0fa..628527d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -77,6 +77,8 @@ libdivecomputer.exp: libdivecomputer.symbols .rc.lo: $(AM_V_GEN) $(LIBTOOL) --silent --tag=RC --mode=compile $(RC) $< -o $@ +libdivecomputer.lo: revision.h + FORCE: $(top_srcdir)/revision: FORCE @if (test -d $(top_srcdir)/.git && cd $(top_srcdir) \ diff --git a/src/libdivecomputer.rc.in b/src/libdivecomputer.rc.in index 81287f7..f98d2ed 100644 --- a/src/libdivecomputer.rc.in +++ b/src/libdivecomputer.rc.in @@ -1,10 +1,22 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include +#ifdef HAVE_VERSION_SUFFIX +#include "revision.h" +#endif + VS_VERSION_INFO VERSIONINFO FILEVERSION @DC_VERSION_MAJOR@,@DC_VERSION_MINOR@,@DC_VERSION_MICRO@,0 PRODUCTVERSION @DC_VERSION_MAJOR@,@DC_VERSION_MINOR@,@DC_VERSION_MICRO@,0 -FILEFLAGSMASK 0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef HAVE_VERSION_SUFFIX +FILEFLAGS VS_FF_PRERELEASE +#else FILEFLAGS 0 +#endif FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 @@ -21,6 +33,9 @@ BEGIN VALUE "OriginalFilename", "libdivecomputer.dll" VALUE "ProductName", "libdivecomputer" VALUE "ProductVersion", "@VERSION@" +#ifdef HAVE_VERSION_SUFFIX + VALUE "Comments", DC_VERSION_REVISION +#endif END END BLOCK "VarFileInfo" diff --git a/src/version.c b/src/version.c index f110acf..b80f6c8 100644 --- a/src/version.c +++ b/src/version.c @@ -19,8 +19,16 @@ * MA 02110-1301 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include +#ifdef HAVE_VERSION_SUFFIX +#include "revision.h" +#endif + const char * dc_version (dc_version_t *version) { @@ -30,7 +38,11 @@ dc_version (dc_version_t *version) version->micro = DC_VERSION_MICRO; } +#ifdef HAVE_VERSION_SUFFIX + return DC_VERSION " (" DC_VERSION_REVISION ")"; +#else return DC_VERSION; +#endif } int