aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-12-08 12:45:23 +0100
committerJakob Unterwurzacher2021-12-08 12:45:23 +0100
commitde22cb1e5dfba8f8b97a5da671bfb2b1a845afb7 (patch)
tree7fcb89b7d96bdb6ab55323c98de90cb5b8837db3
parent39e736c099876710c1951b313bc09aa686a69e29 (diff)
crossbuild.bash: use shell function instead of variable
This will allow easy expansion of build steps.
-rwxr-xr-xcrossbuild.bash24
1 files changed, 13 insertions, 11 deletions
diff --git a/crossbuild.bash b/crossbuild.bash
index 43bfd32..25eeb91 100755
--- a/crossbuild.bash
+++ b/crossbuild.bash
@@ -1,29 +1,31 @@
-#!/bin/bash -eu
+#!/bin/bash
#
# Build on all supported architectures & operating systems
-cd "$(dirname "$0")"
+function build {
+ # Discard resulting binary by writing to /dev/null
+ go build -tags without_openssl -o /dev/null
+}
-export GO111MODULE=on
-# Discard resulting binary by writing to /dev/null
-B="go build -tags without_openssl -o /dev/null"
+set -eux
-set -x
+cd "$(dirname "$0")"
+export GO111MODULE=on
export CGO_ENABLED=0
-GOOS=linux GOARCH=amd64 $B
+GOOS=linux GOARCH=amd64 build
# See https://github.com/golang/go/wiki/GoArm
-GOOS=linux GOARCH=arm GOARM=7 $B
-GOOS=linux GOARCH=arm64 $B
+GOOS=linux GOARCH=arm GOARM=7 build
+GOOS=linux GOARCH=arm64 build
# MacOS on Intel
-GOOS=darwin GOARCH=amd64 $B
+GOOS=darwin GOARCH=amd64 build
# MacOS on Apple Silicon M1.
# Go 1.16 added support for the M1 and added ios/arm64,
# so we use this to check if we should attempt a build.
if go tool dist list | grep ios/arm64 ; then
- GOOS=darwin GOARCH=arm64 $B
+ GOOS=darwin GOARCH=arm64 build
fi