[PATCH 2 of 6] Dynamically generate version information from HG
Wald Commits
scm-commit at wald.intevation.org
Fri Apr 25 12:16:55 CEST 2014
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1398420873 0
# Node ID 7a8f5b85fd9a8c1f75c4ef14f7d0013a487c84c1
# Parent 613fbcb5df0c4b17d648dae5103b3fdc58a5447f
Dynamically generate version information from HG
diff -r 613fbcb5df0c -r 7a8f5b85fd9a CMakeLists.txt
--- a/CMakeLists.txt Fri Apr 25 09:03:16 2014 +0000
+++ b/CMakeLists.txt Fri Apr 25 10:14:33 2014 +0000
@@ -21,6 +21,15 @@
include(CTest)
include(GenerateCppcheck)
+include(HGVersion)
+
+if(HG_REVISION)
+ set(PROJECT_VERSION ${HG_REVISION})
+else()
+ set(PROJECT_VERSION unknown)
+endif()
+
+add_definitions(-DVERSION="${PROJECT_VERSION}")
find_package(PolarSSL)
include_directories(${POLARSSL_INCLUDE_DIR})
@@ -102,3 +111,6 @@
# Documentation
configure_file (doc/Doxyfile.in doc/Doxyfile)
add_subdirectory(doc)
+
+# Configure packaging script for testing
+configure_file (packaging/tmp-createpackage.sh.in packaging/tmp-createpackage.sh)
diff -r 613fbcb5df0c -r 7a8f5b85fd9a cmake/HGVersion.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake/HGVersion.cmake Fri Apr 25 10:14:33 2014 +0000
@@ -0,0 +1,57 @@
+# Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+# Software engineering by Intevation GmbH
+#
+# This file is Free Software under the GNU GPL (v>=2)
+# and comes with ABSOLUTELY NO WARRANTY!
+# See LICENSE.txt for details.
+
+# This makes some variables available to generate a nice version number for
+# hg managed repositories.
+# It sets HG_REVISION_TAG to the value of the latest tag
+# HG_REVISION_DIST to the differences between the tag and the current tip
+# HG_REVISION_ID to the actual revision
+# based on code found in the lemon graph library https://lemon.cs.elte.hu
+# HG_REVISON to a nice combination of those.
+find_package(Hg)
+if (HG_FOUND)
+ EXECUTE_PROCESS(
+ COMMAND
+ hg log -r. --template "{latesttag}"
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE HG_REVISION_TAG
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ EXECUTE_PROCESS(
+ COMMAND
+ hg log -r. --template "{latesttagdistance}"
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE HG_REVISION_DIST
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ EXECUTE_PROCESS(
+ COMMAND
+ hg log -r. --template "{node|short}"
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE HG_REVISION_ID
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ IF(HG_REVISION_TAG STREQUAL "")
+ SET(HG_REVISION_ID "hg-tip")
+ ELSE()
+ IF(HG_REVISION_TAG STREQUAL "null")
+ SET(HG_REVISION_TAG "trunk")
+ ELSEIF(HG_REVISION_TAG MATCHES "^r")
+ STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
+ ENDIF()
+ IF(HG_REVISION_DIST STREQUAL "0")
+ SET(HG_REVISION ${HG_REVISION_TAG})
+ ELSE()
+ SET(HG_REVISION
+ "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
+ ENDIF()
+ ENDIF()
+ENDIF()
diff -r 613fbcb5df0c -r 7a8f5b85fd9a packaging/tmp-createpackage.sh.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/packaging/tmp-createpackage.sh.in Fri Apr 25 10:14:33 2014 +0000
@@ -0,0 +1,30 @@
+# Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
+# Software engineering by Intevation GmbH
+#
+# This file is Free Software under the GNU GPL (v>=2)
+# and comes with ABSOLUTELY NO WARRANTY!
+# See LICENSE.txt for details.
+
+#!/bin/bash
+
+#NSSDIR is hackish as this will be replaced by static compiling
+# anyway
+
+NSSDIR="@NSS_INCLUDE_DIRS@/../bin/"
+MYPATH=$(dirname `readlink -f $0`)
+
+TMPDIR=$(mktemp -d)
+
+EXEFILES=$(find . -name cinst.exe -o -name trustbridge.exe -o -name mozilla.exe)
+
+cp $NSSDIR/*.dll $TMPDIR
+cp $EXEFILES $TMPDIR
+
+echo $TMPDIR
+makensis -Dfiles_dir=$TMPDIR \
+ -Dcompany="Bundesamt für Sicherheit in der Informationstechnik" \
+ -Dversion_number=@PROJECT_VERSION@ \
+ -Dsetupname="TrustBridge- at PROJECT_VERSION@.exe" \
+ -Dproductname="TrustBridge" \
+ -Dproductname_short="TrustBridge" $MYPATH/trustbridge.nsi
+rm -r $TMPDIR
More information about the Trustbridge-commits
mailing list