From 750a79eb094340d4939e1fe2f116ce8722598666 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 29 Jul 2019 23:45:47 +0100 Subject: [PATCH 1/3] Update build script --- build | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build b/build index 383b91a0..a787965f 100755 --- a/build +++ b/build @@ -7,24 +7,26 @@ PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)} PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)} LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER" +ARGS="-v" -while getopts "udaitc:l:r" option +while getopts "uaitc:l:dro:" option do - case "${option}" + case "$option" in u) UPX=true;; - d) DEBUG=true;; i) IOS=true;; a) ANDROID=true;; t) TABLES=true;; c) GCFLAGS="$GCFLAGS $OPTARG";; l) LDFLAGS="$LDFLAGS $OPTARG";; - r) RACE="-race";; + d) ARGS="$ARGS -tags debug";; + r) ARGS="$ARGS -race";; + o) ARGS="$ARGS -o $OPTARG";; esac done if [ -z $TABLES ]; then - STRIP="-s -w" + LDFLAGS="$LDFLAGS -s -w" fi if [ $IOS ]; then @@ -42,12 +44,8 @@ elif [ $ANDROID ]; then else for CMD in `ls cmd/` ; do echo "Building: $CMD" + go build $ARGS -ldflags="$LDFLAGS" -gcflags="$GCFLAGS" ./cmd/$CMD - if [ $DEBUG ]; then - go build $RACE -ldflags="$LDFLAGS" -gcflags="$GCFLAGS" -tags debug -v ./cmd/$CMD - else - go build $RACE -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" -v ./cmd/$CMD - fi if [ $UPX ]; then upx --brute $CMD fi From cafa20074c0910224c56953a7aec072974efd446 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 29 Jul 2019 23:50:00 +0100 Subject: [PATCH 2/3] Don't strip debug builds --- build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build b/build index a787965f..046296eb 100755 --- a/build +++ b/build @@ -26,7 +26,9 @@ do done if [ -z $TABLES ]; then - LDFLAGS="$LDFLAGS -s -w" + if [ "$ARGS" == "${ARGS/-tags debug/}" ]; then + LDFLAGS="$LDFLAGS -s -w" + fi fi if [ $IOS ]; then From b4d08f9273fd6ec6c13bc1e1377fb5315d6c2c85 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 30 Jul 2019 00:03:17 +0100 Subject: [PATCH 3/3] Try to be more POSIX-compliant --- build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build b/build index 046296eb..80a971f9 100755 --- a/build +++ b/build @@ -19,16 +19,14 @@ do t) TABLES=true;; c) GCFLAGS="$GCFLAGS $OPTARG";; l) LDFLAGS="$LDFLAGS $OPTARG";; - d) ARGS="$ARGS -tags debug";; + d) ARGS="$ARGS -tags debug" DEBUG=true;; r) ARGS="$ARGS -race";; o) ARGS="$ARGS -o $OPTARG";; esac done -if [ -z $TABLES ]; then - if [ "$ARGS" == "${ARGS/-tags debug/}" ]; then - LDFLAGS="$LDFLAGS -s -w" - fi +if [ -z $TABLES ] && [ -z $DEBUG ]; then + LDFLAGS="$LDFLAGS -s -w" fi if [ $IOS ]; then