-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathupdate-revision-info.sh
More file actions
executable file
·38 lines (32 loc) · 1.04 KB
/
Copy pathupdate-revision-info.sh
File metadata and controls
executable file
·38 lines (32 loc) · 1.04 KB
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
#!/bin/bash
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 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