build: Build universal macOS binary

This makes use of github.com/randall77/makefat in order to generate a
gvproxy-darwin binary containing both the amd64 and arm64 binaries.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Christophe Fergeau
2022-07-13 13:46:44 +02:00
committed by Gerard Braad
parent 6eb1a84d6f
commit d74ccd7e29
3 changed files with 10 additions and 3 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
bin/
./bin/
capture.pcap
tmp/
test/qcon.log

View File

@@ -1,5 +1,6 @@
TAG ?= $(shell git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty)
CONTAINER_RUNTIME ?= podman
TOOLS_BINDIR = $(realpath tools/bin)
LDFLAGS = -ldflags '-s -w'
@@ -41,11 +42,16 @@ image:
${CONTAINER_RUNTIME} build -t quay.io/crcont/gvisor-tap-vsock:$(TAG) -f images/Dockerfile .
.PHONY: cross
cross:
cross: $(TOOLS_BINDIR)/makefat
GOARCH=amd64 GOOS=windows go build $(LDFLAGS) -o bin/gvproxy-windows.exe ./cmd/gvproxy
GOARCH=amd64 GOOS=darwin go build $(LDFLAGS) -o bin/gvproxy-darwin ./cmd/gvproxy
GOARCH=amd64 GOOS=darwin go build $(LDFLAGS) -o bin/gvproxy-darwin-amd64 ./cmd/gvproxy
GOARCH=arm64 GOOS=darwin go build $(LDFLAGS) -o bin/gvproxy-darwin-arm64 ./cmd/gvproxy
GOARCH=amd64 GOOS=linux go build $(LDFLAGS) -o bin/gvproxy-linux ./cmd/gvproxy
cd bin && $(TOOLS_BINDIR)/makefat gvproxy-darwin gvproxy-darwin-amd64 gvproxy-darwin-arm64
# Needed to build macOS universal binary
$(TOOLS_BINDIR)/makefat:
GOBIN=$(TOOLS_BINDIR) go install -mod=mod github.com/randall77/makefat@latest
.PHONY: test-companion
test-companion:

1
tools/bin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
makefat*