3030# docker build -t ethermint/ethermint-builder scripts/ethermint-builder/
3131# docker run --rm -v "$(pwd)":/go/src/github.com/tendermint/ethermint ethermint/ethermint-builder ./scripts/dist_build.sh
3232# Get the git commit
33- GIT_COMMIT=" $( git rev-parse --short HEAD) "
33+ GIT_COMMIT=" $( git rev-parse HEAD) "
3434GIT_DESCRIBE=" $( git describe --tags --always) "
3535GIT_IMPORT=" github.com/tendermint/ethermint/version"
3636
3737# Determine the arch/os combos we're building for
3838XC_ARCH=${XC_ARCH:- " 386 amd64 arm" }
3939XC_OS=${XC_OS:- " solaris darwin freebsd linux windows" }
40+
4041IGNORE=(" darwin/arm solaris/amd64 freebsd/amd64" )
42+ NON_STATIC=(" darwin/386 darwin/amd64" )
43+
4144TARGETS=" "
45+ NON_STATIC_TARGETS=" "
46+
4247for os in $XC_OS ; do
4348 for arch in $XC_ARCH ; do
4449 target=" $os /$arch "
4550
4651 case ${IGNORE[@]} in * $target * ) continue ;; esac
47- TARGETS=" $os /$arch ,$TARGETS "
52+ case ${NON_STATIC[@]} in * $target * )
53+ NON_STATIC_TARGETS=" $target ,$NON_STATIC_TARGETS "
54+ continue ;;
55+ esac
56+
57+ TARGETS=" $target ,$TARGETS "
4858 done
4959done
50- # Remove last comma
51- TARGETS=${TARGETS:: ${# TARGETS} -1}
5260
5361# Delete the old dir
5462echo " ==> Removing old directory..."
@@ -62,13 +70,27 @@ make tools
6270make get_vendor_deps
6371
6472# Build!
65- echo " ==> Building..."
66- xgo -go=" latest" \
73+ if [ ! -z " $TARGETS " ]; then
74+ echo " ==> Building Static Binaries..."
75+ TARGETS=${TARGETS:: ${# TARGETS} -1}
76+ xgo -go=" latest" \
6777 -targets=" ${TARGETS} " \
68- -ldflags " -X ${GIT_IMPORT} .GitCommit='${GIT_COMMIT} ' -X ${GIT_IMPORT} .GitDescribe='${GIT_DESCRIBE} '" \
69- -dest " build/pkg" \
70- -tags=" ${BUILD_TAGS} " \
71- github.com/tendermint/ethermint/cmd/ethermint
78+ -ldflags " -extldflags '-static' -X ${GIT_IMPORT} .GitCommit=${GIT_COMMIT} -X ${GIT_IMPORT} .GitDescribe=${GIT_DESCRIBE} " \
79+ -dest " build/pkg" \
80+ -tags=" ${BUILD_TAGS} " \
81+ ${DIR} /cmd/ethermint
82+ fi
83+
84+ if [ ! -z " $NON_STATIC_TARGETS " ]; then
85+ echo " ==> Building Non-Static Binaries..."
86+ NON_STATIC_TARGETS=${NON_STATIC_TARGETS:: ${# NON_STATIC_TARGETS} -1}
87+ xgo -go=" latest" \
88+ -targets=" ${NON_STATIC_TARGETS} " \
89+ -ldflags " -X ${GIT_IMPORT} .GitCommit=${GIT_COMMIT} -X ${GIT_IMPORT} .GitDescribe=${GIT_DESCRIBE} " \
90+ -dest " build/pkg" \
91+ -tags=" ${BUILD_TAGS} " \
92+ ${DIR} /cmd/ethermint
93+ fi
7294
7395echo " ==> Packaging..."
7496for FILE in $( ls ./build/pkg) ; do
0 commit comments