]> Git Repo - VerusCoin.git/blob - share/genbuild.sh
Replace http with https: in links to the MIT license.
[VerusCoin.git] / share / genbuild.sh
1 #!/bin/sh
2 # Copyright (c) 2016-2019 The Zcash developers
3 # Copyright (c) 2012-2019 The Bitcoin Core developers
4 # Copyright (c) 2012-2019 Bitcoin Developers
5 # Distributed under the MIT software license, see the accompanying
6 # file COPYING or https://www.opensource.org/licenses/mit-license.php .
7
8 if [ $# -gt 1 ]; then
9     cd "$2"
10 fi
11 if [ $# -gt 0 ]; then
12     FILE="$1"
13     shift
14     if [ -f "$FILE" ]; then
15         INFO="$(head -n 1 "$FILE")"
16     fi
17 else
18     echo "Usage: $0 <filename> <srcroot>"
19     exit 1
20 fi
21
22 DESC=""
23 SUFFIX=""
24 LAST_COMMIT_DATE=""
25 if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
26     # clean 'dirty' status of touched files that haven't been modified
27     git diff >/dev/null 2>/dev/null 
28
29     # if latest commit is tagged and not dirty, then override using the tag name
30     RAWDESC=$(git describe --abbrev=0 2>/dev/null)
31     if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
32         git diff-index --quiet HEAD -- && DESC=$RAWDESC
33     fi
34
35     # otherwise generate suffix from git, i.e. string like "59887e8-dirty"
36     SUFFIX=$(git rev-parse --short HEAD)
37     git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty"
38
39     # get a string like "2012-04-10 16:27:19 +0200"
40     LAST_COMMIT_DATE="$(git log -n 1 --format="%ci")"
41 fi
42
43 if [ -n "$DESC" ]; then
44     NEWINFO="#define BUILD_DESC \"$DESC\""
45 elif [ -n "$SUFFIX" ]; then
46     NEWINFO="#define BUILD_SUFFIX $SUFFIX"
47 else
48     NEWINFO="// No build information available"
49 fi
50
51 # only update build.h if necessary
52 if [ "$INFO" != "$NEWINFO" ]; then
53     echo "$NEWINFO" >"$FILE"
54     if [ -n "$LAST_COMMIT_DATE" ]; then
55         echo "#define BUILD_DATE \"$LAST_COMMIT_DATE\"" >> "$FILE"
56     fi
57 fi
This page took 0.02549 seconds and 4 git commands to generate.