Add version.sh

This commit is contained in:
CalciteM Team 2019-08-18 08:10:54 +08:00
parent 4bb76fed88
commit c0132b630e
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,6 @@
#ifudef VERSION_H
#define VERSION_H
#define VERSION_NUMBER $FULL_VERSION
#endif // VERSION_H

28
NineChess/version.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
rm -f include/version.h
git rev-list HEAD | sort > config.git-hash
LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
if [ $LOCALVER \> 1 ] ; then
VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'`
if [ $VER != $LOCALVER ] ; then
VER="$VER+$(($LOCALVER-$VER))"
fi
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7)"
GIT_VERSION=r$VER
else
GIT_VERSION=
VER="x"
fi
rm -f config.git-hash
cat version.h.template | sed "s/\$FULL_VERSION/$GIT_VERSION/g" > include/version.h
echo "Generated version.h"