diff --git a/Makefile b/Makefile index 17b773a56..389063150 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,11 @@ CODECGEN_TARGETS=report/report.codecgen.go render/render.codecgen.go render/deta RM=--rm RUN_FLAGS=-ti BUILD_IN_CONTAINER=true -GO_ENVS=GO15VENDOREXPERIMENT=1 GOGC=off -GO ?= env $(GO_ENVS) go +GO_ENV=GOGC=off +GO=env $(GO_ENV) go +NO_CROSS_COMP=unset GOOS GOHOST +GO_HOST=$(NO_CROSS_COMP); $(GO) +WITH_GO_HOST_ENV=$(NO_CROSS_COMP); $(GO_ENV) GO_BUILD_INSTALL_DEPS=-i GO_BUILD_TAGS='netgo unsafe' GO_BUILD_FLAGS=$(GO_BUILD_INSTALL_DEPS) -ldflags "-extldflags \"-static\" -X main.version=$(SCOPE_VERSION)" -tags $(GO_BUILD_TAGS) @@ -68,15 +71,6 @@ $(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD else -UNAME := $(shell uname) -ifeq ($(UNAME), Darwin) - UNSET_GOARCH_GOOS=unset GOARCH GOOS; - UNSET_GOGC=unset GOGC; -else - UNSET_GOARCH_GOOS=env -u GOGC -u GOOS - UNSET_GOGC=env -u GOGC -endif - $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ @@ -89,12 +83,12 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) } %.codecgen.go: $(CODECGEN_EXE) - rm -f $@ && $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 - cd $(@D) && $(UNSET_GOARCH_GOOS) $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) + rm -f $@; $(GO_HOST) build $(GO_BUILD_FLAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 + cd $(@D) && $(WITH_GO_HOST_ENV) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) $(CODECGEN_EXE): $(CODECGEN_DIR)/*.go mkdir -p $(@D) - $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) + $(GO_HOST) build $(GO_BUILD_FLAGS) -o $@ ./$(CODECGEN_DIR) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @@ -103,7 +97,7 @@ shell: $(SCOPE_BACKEND_BUILD_UPTODATE) /bin/bash tests: $(SCOPE_BACKEND_BUILD_UPTODATE) - $(UNSET_GOGC) $(GO_ENVS) ./tools/test -no-go-get + ./tools/test -no-go-get lint: $(SCOPE_BACKEND_BUILD_UPTODATE) ./tools/lint . diff --git a/experimental/Makefile b/experimental/Makefile index 5f8ea7b33..c489209d9 100644 --- a/experimental/Makefile +++ b/experimental/Makefile @@ -4,7 +4,7 @@ DIRS=$(shell find . -maxdepth 2 -name *.go | xargs -n1 dirname | sort -u) TARGETS=$(join $(patsubst %,%/,$(DIRS)),$(patsubst ./%,%,$(DIRS))) BUILD_IN_CONTAINER=true RM=--rm -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go + all: $(TARGETS) ifeq ($(BUILD_IN_CONTAINER),true) @@ -13,11 +13,11 @@ $(TARGETS): weaveworks/scope-backend-build -C experimental $@ else $(TARGETS): - $(GO) build -ldflags "-extldflags \"-static\"" -tags netgo -o $@ ./$(@D) + go build -ldflags "-extldflags \"-static\"" -tags netgo -o $@ ./$(@D) endif test: - env -u GOGC $(GO) test ./... + go test ./... clean: - $(GO) clean ./... + go clean ./... diff --git a/experimental/demoprobe/Makefile b/experimental/demoprobe/Makefile index b2f4666f0..70334ba49 100644 --- a/experimental/demoprobe/Makefile +++ b/experimental/demoprobe/Makefile @@ -1,20 +1,19 @@ .PHONY: all vet lint build test clean -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go - all: build test vet lint vet: - $(GO) vet ./... + go vet ./... lint: golint . build: - $(GO) build + go build test: - $(GO) test + go test clean: - env -u GOGC $(GO) clean + go clean + diff --git a/experimental/fixprobe/Makefile b/experimental/fixprobe/Makefile index f2bbc9f07..70334ba49 100644 --- a/experimental/fixprobe/Makefile +++ b/experimental/fixprobe/Makefile @@ -1,21 +1,19 @@ .PHONY: all vet lint build test clean -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go - all: build test vet lint vet: - $(GO) vet ./... + go vet ./... lint: golint . build: - $(GO) build + go build test: - env -u GOGC $(GO) test + go test clean: - $(GO) clean + go clean diff --git a/experimental/genreport/Makefile b/experimental/genreport/Makefile index b2f4666f0..70334ba49 100644 --- a/experimental/genreport/Makefile +++ b/experimental/genreport/Makefile @@ -1,20 +1,19 @@ .PHONY: all vet lint build test clean -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go - all: build test vet lint vet: - $(GO) vet ./... + go vet ./... lint: golint . build: - $(GO) build + go build test: - $(GO) test + go test clean: - env -u GOGC $(GO) clean + go clean +