2018-02-19 01:07:27 +03:00
|
|
|
#!/bin/sh
|
2018-12-10 01:31:58 +03:00
|
|
|
|
2019-02-05 14:15:17 +03:00
|
|
|
set -ef
|
|
|
|
|
2019-08-11 00:31:22 +03:00
|
|
|
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
|
2018-12-09 17:32:24 +03:00
|
|
|
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
|
|
|
|
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
|
2018-12-10 01:31:58 +03:00
|
|
|
|
2023-10-28 20:21:26 +03:00
|
|
|
LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
|
2019-07-30 01:45:47 +03:00
|
|
|
ARGS="-v"
|
2018-12-10 01:31:58 +03:00
|
|
|
|
2022-01-30 22:48:32 +03:00
|
|
|
while getopts "utc:l:dro:p" option
|
2018-06-21 11:53:35 +03:00
|
|
|
do
|
2019-07-30 01:45:47 +03:00
|
|
|
case "$option"
|
2018-06-21 11:53:35 +03:00
|
|
|
in
|
|
|
|
u) UPX=true;;
|
2018-12-10 01:31:58 +03:00
|
|
|
t) TABLES=true;;
|
|
|
|
c) GCFLAGS="$GCFLAGS $OPTARG";;
|
|
|
|
l) LDFLAGS="$LDFLAGS $OPTARG";;
|
2019-07-30 02:03:17 +03:00
|
|
|
d) ARGS="$ARGS -tags debug" DEBUG=true;;
|
2019-07-30 01:45:47 +03:00
|
|
|
r) ARGS="$ARGS -race";;
|
|
|
|
o) ARGS="$ARGS -o $OPTARG";;
|
2020-01-06 22:34:03 +03:00
|
|
|
p) ARGS="$ARGS -buildmode=pie";;
|
2018-06-21 11:53:35 +03:00
|
|
|
esac
|
|
|
|
done
|
2018-12-10 01:31:58 +03:00
|
|
|
|
2019-07-30 02:03:17 +03:00
|
|
|
if [ -z $TABLES ] && [ -z $DEBUG ]; then
|
|
|
|
LDFLAGS="$LDFLAGS -s -w"
|
2018-12-10 01:31:58 +03:00
|
|
|
fi
|
|
|
|
|
2022-01-30 22:48:32 +03:00
|
|
|
for CMD in yggdrasil yggdrasilctl ; do
|
|
|
|
echo "Building: $CMD"
|
|
|
|
go build $ARGS -ldflags="$LDFLAGS" -gcflags="$GCFLAGS" ./cmd/$CMD
|
2018-12-10 01:31:58 +03:00
|
|
|
|
2022-01-30 22:48:32 +03:00
|
|
|
if [ $UPX ]; then
|
|
|
|
upx --brute $CMD
|
|
|
|
fi
|
|
|
|
done
|