Include generated git version string in executable and generated stub files

This commit is contained in:
2021-12-30 22:16:41 +01:00
parent be58adaa4a
commit 907e7e7012
4 changed files with 46 additions and 8 deletions

21
resources/version.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
createVersion() {
local gitVersion=`git describe --long --always --dirty`
local versionLoc="../src/version.h"
local currentVersion=$(grep -oP '"\K.*(?=")' $versionLoc 2>/dev/null)
if [ ! -z "$1" ] && [ "$1" == "-d" ]; then
gitVersion="${gitVersion}-debug"
fi
if [ "$gitVersion" == "$currentVersion" ]; then
return 0
else
echo "Creating version header: ${gitVersion}"
cat <<VERSION_END > "$versionLoc"
#define GITVERSION "${gitVersion}"
VERSION_END
fi
}
createVersion $*