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>"
21 ! { git status
--porcelain -uall --ignored "$@" 2>/dev
/null ||
echo '??'; } |
grep -q '?'
26 if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo
share
/genbuild.sh
; then
27 # clean 'dirty' status of touched files that haven't been modified
28 git
diff >/dev
/null
2>/dev
/null
30 # if latest commit is tagged and not dirty, then override using the tag name
31 RAWDESC
=$
(git describe
--abbrev=0 2>/dev
/null
)
32 if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
33 git diff-index
--quiet HEAD
-- && DESC
=$RAWDESC
36 # otherwise generate suffix from git, i.e. string like "59887e8-dirty"
37 SUFFIX
=$
(git rev-parse
--short HEAD
)
38 git diff-index
--quiet HEAD
-- || SUFFIX
="$SUFFIX-dirty"
41 if [ -n "$DESC" ]; then
42 NEWINFO
="#define BUILD_DESC \"$DESC\""
43 elif [ -n "$SUFFIX" ]; then
44 NEWINFO
="#define BUILD_SUFFIX $SUFFIX"
46 NEWINFO
="// No build information available"
49 # only update build.h if necessary
50 if [ "$INFO" != "$NEWINFO" ]; then
51 echo "$NEWINFO" >"$FILE"