crossbuild.bash: use shell function instead of variable

This will allow easy expansion of build steps.
This commit is contained in:
Jakob Unterwurzacher 2021-12-08 12:45:23 +01:00
parent 39e736c099
commit de22cb1e5d

View File

@ -1,29 +1,31 @@
#!/bin/bash -eu #!/bin/bash
# #
# Build on all supported architectures & operating systems # Build on all supported architectures & operating systems
function build {
# Discard resulting binary by writing to /dev/null
go build -tags without_openssl -o /dev/null
}
set -eux
cd "$(dirname "$0")" cd "$(dirname "$0")"
export GO111MODULE=on export GO111MODULE=on
# Discard resulting binary by writing to /dev/null
B="go build -tags without_openssl -o /dev/null"
set -x
export CGO_ENABLED=0 export CGO_ENABLED=0
GOOS=linux GOARCH=amd64 $B GOOS=linux GOARCH=amd64 build
# See https://github.com/golang/go/wiki/GoArm # See https://github.com/golang/go/wiki/GoArm
GOOS=linux GOARCH=arm GOARM=7 $B GOOS=linux GOARCH=arm GOARM=7 build
GOOS=linux GOARCH=arm64 $B GOOS=linux GOARCH=arm64 build
# MacOS on Intel # MacOS on Intel
GOOS=darwin GOARCH=amd64 $B GOOS=darwin GOARCH=amd64 build
# MacOS on Apple Silicon M1. # MacOS on Apple Silicon M1.
# Go 1.16 added support for the M1 and added ios/arm64, # Go 1.16 added support for the M1 and added ios/arm64,
# so we use this to check if we should attempt a build. # so we use this to check if we should attempt a build.
if go tool dist list | grep ios/arm64 ; then if go tool dist list | grep ios/arm64 ; then
GOOS=darwin GOARCH=arm64 $B GOOS=darwin GOARCH=arm64 build
fi fi