Permalink
Browse files

Changed make_git_version_header to allow overriding the build number

I'm using this to let Jenkins inject *its* build number.
  • Loading branch information...
1 parent 342c2bb commit f6c7ac7ad6085639bd14ce61eee506bf7efbbd30 @uliwitness committed Apr 9, 2013
Showing with 20 additions and 5 deletions.
  1. +20 −5 make_git_version_header.sh
@@ -31,7 +31,13 @@
# file defining a SVN_VERSION constant to that value.
#
# This is for a user-visible build number, so we use the number of revisions
-# and not the actual git hash.
+# and not the actual git hash. You can override this value if you want to e.g.
+# have your CI server provide the build number, simply by defining
+# SVN_VERSION_NUM.
+#
+# There is also a SVN_BUILD_MEANS define that is a string with which you can
+# indicate who built it (kind of as a namespace for the build number, e.g.
+# -DSVN_BUILD_MEANS=nightly
#
# The file will be created in the current directory and the subversion
# revision number is extracted from the current folder's .svn/entries
@@ -51,8 +57,17 @@ fullrevnum=`$GIT rev-parse HEAD`
builddate=`date "+%Y-%m-%d"`
# Now write the constant declaration to the file:
-echo "#define SVN_VERSION \"$revnum\"" > svn_version.h
-echo "#define GIT_HASH \"$fullrevnum\"" >> svn_version.h
-echo "#define SVN_VERSION_NUM $revnum" >> svn_version.h
-echo "#define SVN_BUILD_DATE \"$builddate\"" >> svn_version.h
+echo "#define MGVH_TOSTRING2(n) #n" > svn_version.h
+echo "#define MGVH_TOSTRING(n) MGVH_TOSTRING2(n)" >> svn_version.h
+echo "#ifndef SVN_VERSION_NUM" >> svn_version.h
+echo "#define SVN_VERSION_NUM $revnum" >> svn_version.h
+echo "#endif /* SVN_VERSION_NUM */" >> svn_version.h
+echo "#define SVN_VERSION MGVH_TOSTRING(SVN_VERSION_NUM)" >> svn_version.h
+echo "#define GIT_HASH \"$fullrevnum\"" >> svn_version.h
+echo "#define SVN_BUILD_DATE \"$builddate\"" >> svn_version.h
+echo "#ifndef SVN_BUILD_MEANS" >> svn_version.h
+echo "#define SVN_BUILD_MEANS manual" >> svn_version.h
+echo "#endif /* SVN_BUILD_MEANS */" >> svn_version.h
+echo "#define SVN_BUILD_MEANS_STR MGVH_TOSTRING(SVN_BUILD_MEANS)" >> svn_version.h
+
echo "note: Wrote revision $revnum to svn_version.h"

0 comments on commit f6c7ac7

Please sign in to comment.