diff --git a/Makefile b/Makefile index 476cbef04eb..f3551b2e87b 100644 --- a/Makefile +++ b/Makefile @@ -50,13 +50,17 @@ 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" $(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) + if [ "$(GOOS)" = "$*" ]; then \ + GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=1 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -o $@ $(BUILD_PACKAGE);\ + else \ + docker build --build-arg PROJECT=$(REPOPATH) --build-arg TARGETS=$*/$(GOARCH) --build-arg FLAG_LDFLAGS=$(GO_LDFLAGS) -f deploy/cross/Dockerfile -t skaffold/cross .;\ + docker run --rm --entrypoint sh skaffold/cross -c "cat /build/skaffold*" > $@;\ + fi %.sha256: % shasum -a 256 $< > $@ @@ -82,7 +86,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=1 go install -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) $(BUILD_PACKAGE) .PHONY: integration integration: install diff --git a/deploy/cross/Dockerfile b/deploy/cross/Dockerfile new file mode 100644 index 00000000000..4240625b1ce --- /dev/null +++ b/deploy/cross/Dockerfile @@ -0,0 +1,28 @@ +# Copyright 2019 The Skaffold Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM karalabe/xgo-1.12 + +ARG PROJECT +ARG FLAG_LDFLAGS +ARG TARGETS + +ENV PACK cmd/skaffold +ENV EXT_GOPATH /ext-go +ENV FLAG_LDFLAGS $FLAG_LDFLAGS +ENV TARGETS $TARGETS + +WORKDIR /ext-go/src/$PROJECT +COPY . . +RUN /build.sh $PROJECT