2 # Copyright (c) 2012-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
12 if [ -f "$FILE" ]; then
13 INFO
="$(head -n 1 "$FILE")"
16 echo "Usage: $0 <filename> <srcroot>"
22 if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
23 # clean 'dirty' status of touched files that haven't been modified
24 git
diff >/dev
/null
2>/dev
/null
26 # if latest commit is tagged and not dirty, then override using the tag name
27 RAWDESC
=$
(git describe
--abbrev=0 2>/dev
/null
)
28 if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
29 git diff-index
--quiet HEAD
-- && DESC
=$RAWDESC
32 # otherwise generate suffix from git, i.e. string like "59887e8-dirty"
33 SUFFIX
=$
(git rev-parse
--short HEAD
)
34 git diff-index
--quiet HEAD
-- || SUFFIX
="$SUFFIX-dirty"
37 if [ -n "$DESC" ]; then
38 NEWINFO
="#define BUILD_DESC \"$DESC\""
39 elif [ -n "$SUFFIX" ]; then
40 NEWINFO
="#define BUILD_SUFFIX $SUFFIX"
42 NEWINFO
="// No build information available"
45 # only update build.h if necessary
46 if [ "$INFO" != "$NEWINFO" ]; then
47 echo "$NEWINFO" >"$FILE"