6 if [ -f "$FILE" ]; then
7 INFO="$(head -n 1 "$FILE")"
10 echo "Usage: $0 <filename>"
14 if [ -e "$(which git)" ]; then
15 # clean 'dirty' status of touched files that haven't been modified
16 git diff >/dev/null 2>/dev/null
18 # get a string like "v0.6.0-66-g59887e8-dirty"
19 DESC="$(git describe --dirty 2>/dev/null)"
21 # get a string like "2012-04-10 16:27:19 +0200"
22 TIME="$(git log -n 1 --format="%ci")"
25 if [ -n "$DESC" ]; then
26 NEWINFO="#define BUILD_DESC \"$DESC\""
28 NEWINFO="// No build information available"
31 # only update build.h if necessary
32 if [ "$INFO" != "$NEWINFO" ]; then
33 echo "$NEWINFO" >"$FILE"
34 echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"