5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-09-19 16:09:36 +00:00

Add -t, -c and -l to build script for specifying DWARF tables, GCFLAGS and LDFLAGS

This commit is contained in:
Neil Alexander 2018-12-09 22:31:58 +00:00
parent ff49ca6d30
commit bec044346e
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

21
build
View File

@ -1,23 +1,34 @@
#!/bin/sh #!/bin/sh
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil} PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil}
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)} PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)} PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
while getopts "ud" option
LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
while getopts "udtc:l:" option
do do
case "${option}" case "${option}"
in in
u) UPX=true;; u) UPX=true;;
d) DEBUG=true;; d) DEBUG=true;;
t) TABLES=true;;
c) GCFLAGS="$GCFLAGS $OPTARG";;
l) LDFLAGS="$LDFLAGS $OPTARG";;
esac esac
done done
echo "Downloading..."
if [ -z $TABLES ]; then
STRIP="-s -w"
fi
for CMD in `ls cmd/` ; do for CMD in `ls cmd/` ; do
echo "Building: $CMD" echo "Building: $CMD"
IMPRINT="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
if [ $DEBUG ]; then if [ $DEBUG ]; then
go build -ldflags="$IMPRINT" -tags debug -v ./cmd/$CMD go build -ldflags="$LDFLAGS" -gcflags="$GCFLAGS" -tags debug -v ./cmd/$CMD
else else
go build -ldflags="$IMPRINT -s -w" -v ./cmd/$CMD go build -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" -v ./cmd/$CMD
fi fi
if [ $UPX ]; then if [ $UPX ]; then
upx --brute $CMD upx --brute $CMD