-
Notifications
You must be signed in to change notification settings - Fork 46
/
.build.sh
executable file
·76 lines (61 loc) · 2.26 KB
/
.build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This file is used in the reproducible cross platform builder for the Althea chain, it has to be at the top level
# due to some expectations of the docker container doing the building, which is based off of Gaia's version
#!/bin/bash
set -uex
# Expect the following envvars to be set:
# - APP
# - VERSION
# - COMMIT
# - TARGET_OS
# - LEDGER_ENABLED
# - DEBUG
# allow git to grab the submodules
git config --global --add safe.directory /sources
# Source builder's functions library
. /usr/local/share/tendermint/buildlib.sh
# These variables are now available
# - BASEDIR
# - OUTDIR
JS_CONTRACTS_ABI="solidity/artifacts/contracts"
GO_CONTRACTS_ABI="contracts/compiled"
export LEDGER_ENABLED=true
# Build for each os-architecture pair
for platform in ${TARGET_PLATFORMS} ; do
# This function sets GOOS, GOARCH, and OS_FILE_EXT environment variables
# according to the build target platform. OS_FILE_EXT is empty in all
# cases except when the target platform is 'windows'.
setup_build_env_for_platform "${platform}"
# build linux builds with security features these env vars
# are not unset, so it's important to run the linux builds last
if [[ $platform == linux* ]] ;
then
export GOFLAGS='-buildmode=pie'
export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CGO_LDFLAGS="-Wl,-z,relro,-z,now -fstack-protector"
fi
make clean
make contracts
for f in $(ls $JS_CONTRACTS_ABI | grep -v Test); do
source="${f%.sol}.json"
out="${source%.json}-js.json"
cp $JS_CONTRACTS_ABI/$f/$source ${OUTDIR}/$out
done
for f in $(ls $GO_CONTRACTS_ABI | grep -v Test ); do
out="${f%.json}-go.json"
cp $GO_CONTRACTS_ABI/$f ${OUTDIR}/$out
done
echo Building for $(go env GOOS)/$(go env GOARCH) >&2
GOROOT_FINAL="$(go env GOROOT)" \
make build \
LDFLAGS=-buildid=${VERSION} \
VERSION=${VERSION} \
COMMIT=${COMMIT} \
LEDGER_ENABLED=${LEDGER_ENABLED}
mv ./build/${APP}${OS_FILE_EXT} ${OUTDIR}/${APP}-${VERSION}-$(go env GOOS)-$(go env GOARCH)${OS_FILE_EXT}
# This function restore the build environment variables to their
# original state.
restore_build_env
done
# Generate and display build report.
generate_build_report
cat ${OUTDIR}/build_report