Skip to content

Commit

Permalink
Update genbuild.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
vashshawn authored Sep 2, 2024
1 parent 6f2d31d commit e71accd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions share/genbuild.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh
# Needs root

if [ $# -gt 0 ]; then
FILE="$1"
shift
if [ -f "$FILE" ]; then
INFO="$(head -n 1 "$FILE")"
else
INFO=""
fi
else
echo "Usage: $0 <filename>"
Expand All @@ -13,13 +15,16 @@ fi

if [ -e "$(which git)" ]; then
# clean 'dirty' status of touched files that haven't been modified
git diff >/dev/null 2>/dev/null
git diff >/dev/null 2>/dev/null

# get a string like "v0.6.0-66-g59887e8-dirty"
DESC="$(git describe --dirty 2>/dev/null)"

# get a string like "2012-04-10 16:27:19 +0200"
TIME="$(git log -n 1 --format="%ci")"
else
DESC=""
TIME=""
fi

if [ -n "$DESC" ]; then
Expand All @@ -31,5 +36,7 @@ fi
# only update build.h if necessary
if [ "$INFO" != "$NEWINFO" ]; then
echo "$NEWINFO" >"$FILE"
echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"
if [ -n "$TIME" ]; then
echo "#define BUILD_DATE \"$TIME\"" >>"$FILE"
fi
fi

0 comments on commit e71accd

Please sign in to comment.