changed generation of git-revision.h which allows to keep it up-to-date. Aditionally git-branch info has been added.

This commit is contained in:
2017-02-22 09:42:07 +01:00
parent cc1679144c
commit fca13283e1
16 changed files with 73 additions and 28 deletions

28
src/git_revision.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
echo "Generating header for git hash" $1 $2
GIT_HEADER="$1/$2"
if [ -z "$2" ]; then
GIT_HEADER="$1/git-revision.h"
fi
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
GIT_VERSION=`git log -n 1 --pretty=format:"%ad - %h"`
if grep --quiet "$GIT_VERSION" $GIT_HEADER; then
echo "No need to generate new $GIT_HEADER - git hash is unchanged"
exit 0;
fi
echo "git branch is : " $GIT_BRANCH
echo "git version is : " $GIT_VERSION
echo "#ifndef GIT_VERSION_H" > $GIT_HEADER
echo "#define GIT_VERSION_H" >> $GIT_HEADER
echo "" >> $GIT_HEADER
echo "#define GIT_BRANCH \"$GIT_BRANCH\"" >> $GIT_HEADER
echo "#define GIT_CURRENT_SHA1 \"$GIT_VERSION\"" >> $GIT_HEADER
echo "" >> $GIT_HEADER
echo "#endif //GIT_VERSION_H" >> $GIT_HEADER
echo "file is generated into" $GIT_HEADER