-
Notifications
You must be signed in to change notification settings - Fork 66
/
update-revision-info.sh
executable file
·42 lines (36 loc) · 1.14 KB
/
update-revision-info.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
30
31
32
33
34
35
36
37
38
39
40
41
42
#/bin/sh
FRDIR=`dirname $0`
REVISIONINFOFILE=src/revisioninfo.h
# this will already contain the quotes needed in the header file
GITHASH="";
if [ -x "$(command -v git 2>/dev/null)" ]; then
GITHASH=`git log -1 --pretty=format:%h $FRDIR 2>/dev/null`
if [ "$GITHASH" != "" ]; then
GITHASH="\"$GITHASH\""
fi
fi
#if [ "$GITHASH" != "" ]; then
# echo "git hash $GITHASH"
#else
# echo "no git hash found"
#fi
if test -f $REVISIONINFOFILE ; then
HEADER_GITHASH=`awk '/FR_GIT_HASH/{print $3}' $REVISIONINFOFILE`
if [ "$HEADER_GITHASH" != "$GITHASH" ]; then
echo "git hash has changed from $HEADER_GITHASH to $GITHASH"
WRITE_HEADER="y"
fi
else
echo "$REVISIONINFOFILE not found"
WRITE_HEADER="y"
fi
if [ "$WRITE_HEADER" = "y" ]; then
echo "// auto-generated by update-revision-info script" > $REVISIONINFOFILE
if [ "$GITHASH" != "" ]; then
echo "Writing git hash $GITHASH to $REVISIONINFOFILE"
echo "#define FR_GIT_HASH $GITHASH" >> $REVISIONINFOFILE
else
echo "Writing no git hash to $REVISIONINFOFILE"
echo "#undef FR_GIT_HASH" >> $REVISIONINFOFILE
fi
fi