diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-01-30 18:56:12 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-15 06:19:33 -0800 |
commit | f6dbed1fc6c71251e1937cb1b63e96ff7a8251c3 (patch) | |
tree | 709da15b9ead9d44198953765e06409355b43d56 /scripts/write-version | |
parent | 27b4d10f91e4cab61756747d5b8d0f17a29d3e7a (diff) | |
download | subsurface-f6dbed1fc6c71251e1937cb1b63e96ff7a8251c3.tar.gz |
qmake: use a dedicated build script to generate ssrf-version.h
- added ./scripts/write-version
- subsurface-gen-version.pri is much simpler now
- .git/HEAD is no longer used explicitly in .pro/.pri files
- the version_h rule is called on each 'make' invocation
but recompilation will occur only if ssrf-version.h
is updated by ./scripts/write-version
- qmake now depends on the existence of ssrf-version.h
so it creates an empty one on Makefile generation so
that a warning is not shown
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'scripts/write-version')
-rw-r--r-- | scripts/write-version | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/write-version b/scripts/write-version new file mode 100644 index 000000000..81562fbb8 --- /dev/null +++ b/scripts/write-version @@ -0,0 +1,49 @@ +#!/bin/sh + +# +# arguments: +# $1 - target H file +# $2 - fallback version string +# $3 - os name {linux|darwin|win} +# +# doesn't have much error checking! +# should be started from where .git is! +# + +if [ "$#" -lt 3 ]; then + echo "ERROR: missing arguments"; + exit 1; +fi + +# set OS and TARGET +TARGET=$1 +TARGET_TEMP=$TARGET.tmp +VERSION=$2 +OS=$3 + +# get the full version: git based or hardcoded from .gitversion or the fallback version string +if gitpwd=`git rev-parse --show-toplevel 2> /dev/null`; then + FULL_VER=`sh "$gitpwd/scripts/get-version" linux` +else + FULL_VER=`cat .gitversion 2> /dev/null || echo $VERSION` +fi + +# grab some strings from get-version +CANONICAL_VER=`sh ./scripts/get-version full $FULL_VER` +OS_USABLE_VER=`sh ./scripts/get-version $OS $FULL_VER` + +# write to a temp file +echo "#define VERSION_STRING \"$OS_USABLE_VER\"" > $TARGET_TEMP +echo "#define GIT_VERSION_STRING \"$FULL_VER\"" >> $TARGET_TEMP +echo "#define CANONICAL_VERSION_STRING \"$CANONICAL_VER\"" >> $TARGET_TEMP + +# if the target file is missing create it +if [ ! -f $TARGET ]; then + CMD=`touch $TARGET` +fi + +# if the temp file and the target file differ, replace the target file with the temp file +CMD=`diff -q $TARGET $TARGET_TEMP || cp $TARGET_TEMP $TARGET` + +# remove the temp file +CMD=`rm -f $TARGET_TEMP` |