github.com/tumi8/quic-go@v0.37.4-tum/.github/workflows/cross-compile.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 dist="$1" 6 goos=$(echo "$dist" | cut -d "/" -f1) 7 goarch=$(echo "$dist" | cut -d "/" -f2) 8 9 # cross-compiling for android is a pain... 10 if [[ "$goos" == "android" ]]; then exit; fi 11 # iOS builds require Cgo, see https://github.com/golang/go/issues/43343 12 # Cgo would then need a C cross compilation setup. Not worth the hassle. 13 if [[ "$goos" == "ios" ]]; then exit; fi 14 15 # Write all log output to a temporary file instead of to stdout. 16 # That allows running this script in parallel, while preserving the correct order of the output. 17 log_file=$(mktemp) 18 19 error_handler() { 20 cat "$log_file" >&2 21 rm "$log_file" 22 exit 1 23 } 24 25 trap 'error_handler' ERR 26 27 echo "$dist" >> "$log_file" 28 out="main-$goos-$goarch" 29 GOOS=$goos GOARCH=$goarch go build -o $out example/main.go >> "$log_file" 2>&1 30 rm $out 31 32 cat "$log_file" 33 rm "$log_file"