Skip to content

Commit

Permalink
Cross compile Skaffold, with CGO=1, using xgo
Browse files Browse the repository at this point in the history
Fixes #1936

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Apr 23, 2019
1 parent 86d72b0 commit d126947
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $< > $@
Expand All @@ -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
Expand Down

0 comments on commit d126947

Please sign in to comment.