-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen-revision.sh
45 lines (42 loc) · 930 Bytes
/
gen-revision.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
43
44
45
#!/bin/sh
#
# Generate CPP define for a SVN revision number if sources are from SVN
# (and svn is available). Otherwise, define the revision number to be 0.
#
TOP=$1
DEFN=$2
if [ "${TOP}" = "" -o "${DEFN}" = "" ]; then
echo "Usage: gen-revision.sh [top-dir] [define]"
exit 1
fi
echo "/* Generated by gen-revision.sh */"
echo "#ifndef $DEFN"
if [ -e "${TOP}/.svn" ]; then
IFS=":"
SVN=""
for path in $PATH; do
if [ -x "${path}/svn" ]; then
SVN="${path}/svn"
break
elif [ -x "${path}/svn.exe" ]; then
SVN="${path}/svn.exe"
break
fi
done
if [ "${SVN}" != "" ]; then
SVN_REV=`${SVN} info --show-item revision`
if [ "$?" = "0" -a "$SVN_REV" != "" ]; then
echo "#define $DEFN $SVN_REV"
else
echo '/* svn info failed */'
echo "#define $DEFN 0"
fi
else
echo '/* svn not found */'
echo "#define $DEFN 0"
fi
else
echo '/* not using SVN sources */'
echo "#define $DEFN 0"
fi
echo '#endif'