Improve version.h file generation

Store full revision hash in REVISION file. Write fixes 10 chars of revision
hash to version.h. Use `#pragma once` in version.h. Support getting revision
from TeamCity environment variable (similar to Jenkins).
This commit is contained in:
Mike Gelfand
2017-01-15 00:54:56 +03:00
parent f6b23c02f0
commit 7f008edab6
3 changed files with 22 additions and 16 deletions

View File

@@ -23,16 +23,18 @@ minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'`
vcs_revision=
vcs_revision_file=REVISION
if [ -n "$JENKINS_URL" -a -n "$VCS_REVISION" ]; then
# Jenkins automated build, use the set environment variables to avoid
# version mismatches between java's svn and command line's svn
vcs_revision=$VCS_REVISION
if [ -n "$JENKINS_URL" -a -n "$GIT_COMMIT" ]; then
vcs_revision=$GIT_COMMIT
elif [ -n "$TEAMCITY_PROJECT_NAME" -a -n "$BUILD_VCS_NUMBER" ]; then
vcs_revision=$BUILD_VCS_NUMBER
elif [ -d ".git" ] && type git >/dev/null 2>&1; then
vcs_revision=`git rev-list --max-count=1 --abbrev-commit HEAD`
vcs_revision=`git rev-list --max-count=1 HEAD`
elif [ -f "$vcs_revision_file" ]; then
vcs_revision=`cat "$vcs_revision_file"`
fi
vcs_revision=`echo $vcs_revision`
if [ -n "$vcs_revision" ]; then
[ -f "$vcs_revision_file" ] && [ "`cat "$vcs_revision_file"`" = "$vcs_revision" ] || echo "$vcs_revision" > "$vcs_revision_file"
else
@@ -40,7 +42,11 @@ else
rm -f "$vcs_revision_file"
fi
vcs_revision=${vcs_revision:0:10}
cat > libtransmission/version.h.new << EOF
#pragma once
#define PEERID_PREFIX "${peer_id_prefix}"
#define USERAGENT_PREFIX "${user_agent_prefix}"
#define VCS_REVISION "${vcs_revision}"