From d126947e37055bca9dfbddc737fa0769ffed4b13 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Tue, 23 Apr 2019 16:48:23 +0200 Subject: [PATCH] Cross compile Skaffold, with CGO=1, using xgo Fixes #1936 Signed-off-by: David Gageot --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 290fd85fdaf..5a455754958 100644 --- a/Makefile +++ b/Makefile @@ -47,15 +47,19 @@ GO_LDFLAGS += -X $(VERSION_PACKAGE).gitTreeState=$(if $(shell git status --porce GO_LDFLAGS +=" GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*") -GO_BUILD_TAGS := "kqueue" DOCSY_COMMIT:=a7141a2eac26cb598b707cab87d224f9105c315d $(BUILD_DIR)/$(PROJECT): $(BUILD_DIR)/$(PROJECT)-$(GOOS)-$(GOARCH) cp $(BUILD_DIR)/$(PROJECT)-$(GOOS)-$(GOARCH) $@ -$(BUILD_DIR)/$(PROJECT)-%-$(GOARCH): $(GO_FILES) $(BUILD_DIR) - GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(BUILD_PACKAGE) +.PHONY: xgo +xgo: + go get github.com/karalabe/xgo + +$(BUILD_DIR)/$(PROJECT)-%-$(GOARCH): xgo $(GO_FILES) $(BUILD_DIR) + xgo -go 1.12 -dest $(BUILD_DIR) -out $(PROJECT) --pkg cmd/skaffold --targets=$*/$(GOARCH) -ldflags $(GO_LDFLAGS) . + mv $(BUILD_DIR)/$(PROJECT)-$** $@ %.sha256: % shasum -a 256 $< > $@ @@ -81,7 +85,7 @@ test: $(BUILD_DIR) .PHONY: install install: $(GO_FILES) $(BUILD_DIR) - GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go install -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) $(BUILD_PACKAGE) + GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go install -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) $(BUILD_PACKAGE) .PHONY: integration integration: install