2012-04-07 02:06:53 +02:00
|
|
|
#!/bin/sh
|
2019-12-31 18:35:41 +01:00
|
|
|
# Copyright (c) 2012-2019 The Bitcoin Core developers
|
2016-09-29 07:57:47 +02:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-06-18 13:12:07 +02:00
|
|
|
export LC_ALL=C
|
2013-05-28 01:55:01 +02:00
|
|
|
if [ $# -gt 1 ]; then
|
2017-12-04 22:18:45 +01:00
|
|
|
cd "$2" || exit 1
|
2013-05-28 01:55:01 +02:00
|
|
|
fi
|
2012-04-07 02:06:53 +02:00
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
FILE="$1"
|
|
|
|
shift
|
|
|
|
if [ -f "$FILE" ]; then
|
|
|
|
INFO="$(head -n 1 "$FILE")"
|
|
|
|
fi
|
|
|
|
else
|
2013-05-28 01:55:01 +02:00
|
|
|
echo "Usage: $0 <filename> <srcroot>"
|
2012-04-07 02:06:53 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-12 04:43:42 +01:00
|
|
|
GIT_DESCRIPTION=""
|
2020-04-28 10:28:34 +02:00
|
|
|
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
|
2012-04-07 02:06:53 +02:00
|
|
|
# clean 'dirty' status of touched files that haven't been modified
|
2019-07-05 03:00:44 +02:00
|
|
|
git diff >/dev/null 2>/dev/null
|
2012-04-07 02:06:53 +02:00
|
|
|
|
2024-01-12 04:43:42 +01:00
|
|
|
# override using the tag name from git, i.e. string like "v20.0.0-beta.8-5-g99786590df6f-dirty"
|
|
|
|
GIT_DESCRIPTION=$(git describe --abbrev=12 --dirty 2>/dev/null)
|
2012-04-07 02:06:53 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-12 04:43:42 +01:00
|
|
|
if [ -n "$GIT_DESCRIPTION" ]; then
|
|
|
|
NEWINFO="#define BUILD_GIT_DESCRIPTION \"$GIT_DESCRIPTION\""
|
2012-04-07 02:06:53 +02:00
|
|
|
else
|
|
|
|
NEWINFO="// No build information available"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# only update build.h if necessary
|
|
|
|
if [ "$INFO" != "$NEWINFO" ]; then
|
|
|
|
echo "$NEWINFO" >"$FILE"
|
|
|
|
fi
|