-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.sh
executable file
·30 lines (27 loc) · 933 Bytes
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
VERSION="012"
DATE=`date`
SYSTEM=`uname -a`
MACHINE=`uname -m`
OS=`uname`
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))"
elif git status | grep -q "modified:" ; then
VER="${VER}M"
fi
VER="$VER [$(git rev-list HEAD -n 1 | head -c 7)]"
echo "#define NGTC_VERSION \"v$VERSION r$VER\"" > version.h
else
echo "#define NGTC_VERSION \"$VERSION\"" > version.h
VER="x"
fi
echo "#define NGTC_NUMBER_VERSION \"$VERSION.$VER\"" >>version.h
echo "#define SYSTEM_VERSION \"$SYSTEM\"" >>version.h
echo "#define BUILD_DATE \"$DATE\"" >>version.h
echo "#define MACHINE \"$MACHINE\"" >>version.h
echo "#define OS \"$OS\"" >>version.h
rm -f config.git-hash