Use go build instead of go install

go install doesn't like to cross-compile things. (Try running build.sh with GOARCH set to something other than what it "should" be.)

With go build, it appears that cross-compilation is really, really straightforward. Simply install a compiler for your target platform and set `GOARCH` and `CC` accordingly.
This commit is contained in:
Caleb Xavier Berger 2021-01-18 03:41:46 -05:00 committed by GitHub
parent fdd534f86a
commit aa2bd39969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,13 @@ else
export FLAGS="" export FLAGS=""
fi fi
go install -trimpath -ldflags "$FLAGS" -v $PWD/`dirname $0`/cmd/... for pkg in ./cmd/*; do
if [[ -d "$pkg" && ! -L "$pkg" ]]; then
# https://unix.stackexchange.com/a/94307/125869
pkg_x="$(basename -- "$pkg"; echo .)"
base="${pkg_x%??}"
CGO_ENABLED=1 go build -trimpath -ldflags "$FLAGS" -v -o "./bin/$base" "./cmd/$base"
fi
done
GOOS=js GOARCH=wasm go build -trimpath -ldflags "$FLAGS" -o bin/main.wasm ./cmd/dendritejs CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -ldflags "$FLAGS" -o bin/main.wasm ./cmd/dendritejs