From 805bedf3e16cc12945f993cea67547ddf1c6c8bb Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 24 Feb 2016 17:06:43 +0000 Subject: [PATCH 01/10] Create codecgen binary based on the host's architecture --- .gitignore | 2 +- Makefile | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3c5e1474c..3744f2783 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,6 @@ experimental/_integration/_integration *npm-debug.log app/static.go prog/static.go -vendor/github.com/ugorji/go/codec/codecgen/codecgen +vendor/github.com/ugorji/go/codec/codecgen/bin/* *.codecgen.go *.generated.go diff --git a/Makefile b/Makefile index bd3ec046f..ba2487a9f 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ DOCKER_DISTRIB=.pkg/docker-$(DOCKER_VERSION).tgz DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(DOCKER_VERSION).tgz RUNSVINIT=vendor/runsvinit/runsvinit CODECGEN_DIR=vendor/github.com/ugorji/go/codec/codecgen -CODECGEN_EXE=$(CODECGEN_DIR)/codecgen +CODECGEN_EXE=$(CODECGEN_DIR)/bin/codecgen_$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) GET_CODECGEN_DEPS=$(shell find $(1) -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' -not -name '*.codecgen.go' -not -name '*.generated.go') CODECGEN_TARGETS=report/report.codecgen.go render/render.codecgen.go render/detailed/detailed.codecgen.go RM=--rm @@ -83,7 +83,8 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) cd $(@D) && env -u GOARCH -u GOOS GOGC=off $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) $(CODECGEN_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) - env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(@D) + mkdir -p $(@D) + env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @@ -147,7 +148,7 @@ clean: # $(SUDO) docker rmi $(SCOPE_UI_BUILD_IMAGE) $(SCOPE_BACKEND_BUILD_IMAGE) >/dev/null 2>&1 || true rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \ $(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/app.js docker/weave .pkg \ - $(CODECGEN_TARGETS) $(CODECGEN_EXE) + $(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin/* deps: $(GO) get -u -f -tags $(GO_BUILD_TAGS) \ From ab6b00adf9c0bde38a07125670ea0bee5b6fad26 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 25 Feb 2016 09:35:31 +0000 Subject: [PATCH 02/10] Provide identical go variables to codecgen --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ba2487a9f..9d8cae3c5 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ CODECGEN_TARGETS=report/report.codecgen.go render/render.codecgen.go render/deta RM=--rm RUN_FLAGS=-ti BUILD_IN_CONTAINER=true -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go +GO_ENVS=GO15VENDOREXPERIMENT=1 GOGC=off +GO ?= env $(GO_ENVS) go 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) @@ -80,7 +81,7 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) %.codecgen.go: $(SCOPE_BACKEND_BUILD_UPTODATE) rm -f $@ && env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 - cd $(@D) && env -u GOARCH -u GOOS GOGC=off $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) + cd $(@D) && env -u GOARCH -u GOOS $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) $(CODECGEN_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) mkdir -p $(@D) From 783297672c0e353774bfa0fba3ca95d95e3a4dcb Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 25 Feb 2016 09:42:42 +0000 Subject: [PATCH 03/10] Invoke Go consistently and remove GO15VENDOREXPERIMENT from container --- Makefile | 2 +- backend/Dockerfile | 1 - experimental/Makefile | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9d8cae3c5..c602831f1 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ shell: $(SCOPE_BACKEND_BUILD_UPTODATE) /bin/bash tests: $(SCOPE_BACKEND_BUILD_UPTODATE) - ./tools/test -no-go-get + env -u GOGC $(GO_ENVS) ./tools/test -no-go-get lint: $(SCOPE_BACKEND_BUILD_UPTODATE) ./tools/lint . diff --git a/backend/Dockerfile b/backend/Dockerfile index 85b36ec3b..566bb049e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,4 @@ FROM golang:1.6.0 -ENV GO15VENDOREXPERIMENT 1 RUN apt-get update && apt-get install -y libpcap-dev python-requests time RUN go clean -i net && go install -tags netgo std && go install -race -tags netgo std RUN go get -tags netgo \ diff --git a/experimental/Makefile b/experimental/Makefile index c489209d9..5f8ea7b33 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: - go test ./... + env -u GOGC $(GO) test ./... clean: - go clean ./... + $(GO) clean ./... From 8ac9e7812ca4246c1ca51b4d576bc66ce1fad780 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 25 Feb 2016 12:10:37 +0000 Subject: [PATCH 04/10] Extend go variables even more --- experimental/demoprobe/Makefile | 11 ++++++----- experimental/fixprobe/Makefile | 10 ++++++---- experimental/genreport/Makefile | 11 ++++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/experimental/demoprobe/Makefile b/experimental/demoprobe/Makefile index 70334ba49..b2f4666f0 100644 --- a/experimental/demoprobe/Makefile +++ b/experimental/demoprobe/Makefile @@ -1,19 +1,20 @@ .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: - go clean - + env -u GOGC $(GO) clean diff --git a/experimental/fixprobe/Makefile b/experimental/fixprobe/Makefile index 70334ba49..f2bbc9f07 100644 --- a/experimental/fixprobe/Makefile +++ b/experimental/fixprobe/Makefile @@ -1,19 +1,21 @@ .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 + env -u GOGC $(GO) test clean: - go clean + $(GO) clean diff --git a/experimental/genreport/Makefile b/experimental/genreport/Makefile index 70334ba49..b2f4666f0 100644 --- a/experimental/genreport/Makefile +++ b/experimental/genreport/Makefile @@ -1,19 +1,20 @@ .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: - go clean - + env -u GOGC $(GO) clean From 3391bcc62c352db5006c305b64929e9594a8c082 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 25 Feb 2016 16:20:32 +0000 Subject: [PATCH 05/10] Move codecgen dependencies to the no-containerized section --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index c602831f1..dace9fec7 100644 --- a/Makefile +++ b/Makefile @@ -47,16 +47,15 @@ $(RUNSVINIT): vendor/runsvinit/*.go $(SCOPE_EXE): $(shell find ./ -path ./vendor -prune -o -type f -name *.go) prog/static.go $(CODECGEN_TARGETS) -report/report.codecgen.go: $(call GET_CODECGEN_DEPS,report/) $(CODECGEN_EXE) -render/render.codecgen.go: $(call GET_CODECGEN_DEPS,render/) $(CODECGEN_EXE) -render/detailed/detailed.codecgen.go: $(call GET_CODECGEN_DEPS,render/detailed/) $(CODECGEN_EXE) -$(CODECGEN_EXE): $(CODECGEN_DIR)/*.go +report/report.codecgen.go: $(call GET_CODECGEN_DEPS,report/) +render/render.codecgen.go: $(call GET_CODECGEN_DEPS,render/) +render/detailed/detailed.codecgen.go: $(call GET_CODECGEN_DEPS,render/detailed/) static: prog/static.go prog/static.go: client/build/app.js ifeq ($(BUILD_IN_CONTAINER),true) -$(SCOPE_EXE) $(RUNSVINIT) $(CODECGEN_TARGETS) $(CODECGEN_EXE) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD_UPTODATE) +$(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD_UPTODATE) @mkdir -p $(shell pwd)/.pkg $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd):/go/src/github.com/weaveworks/scope \ @@ -79,11 +78,11 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) false; \ } -%.codecgen.go: $(SCOPE_BACKEND_BUILD_UPTODATE) +%.codecgen.go: $(CODECGEN_EXE) rm -f $@ && env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 cd $(@D) && env -u GOARCH -u GOOS $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) -$(CODECGEN_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) +$(CODECGEN_EXE): $(CODECGEN_DIR)/*.go mkdir -p $(@D) env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) From d7e9d1388fa7e2658b1da38a11401a93f8ad4696 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Thu, 10 Mar 2016 11:22:33 +0100 Subject: [PATCH 06/10] Support `env -u` e.g. unsetting vars under OSX --- Makefile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index dace9fec7..17b773a56 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ 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) + all: $(SCOPE_EXPORT) $(DOCKER_DISTRIB): @@ -67,6 +68,15 @@ $(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 || { \ @@ -79,12 +89,12 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) } %.codecgen.go: $(CODECGEN_EXE) - rm -f $@ && env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 - cd $(@D) && env -u GOARCH -u GOOS $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) + 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))) $(CODECGEN_EXE): $(CODECGEN_DIR)/*.go mkdir -p $(@D) - env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) + $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @@ -93,7 +103,7 @@ shell: $(SCOPE_BACKEND_BUILD_UPTODATE) /bin/bash tests: $(SCOPE_BACKEND_BUILD_UPTODATE) - env -u GOGC $(GO_ENVS) ./tools/test -no-go-get + $(UNSET_GOGC) $(GO_ENVS) ./tools/test -no-go-get lint: $(SCOPE_BACKEND_BUILD_UPTODATE) ./tools/lint . From e7c38a9de2e4135aa0c551d80c2bc3e66bbc6b6c Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Sat, 12 Mar 2016 13:57:21 +0000 Subject: [PATCH 07/10] Simplify build * Get rid of GO15VENDOREXPERIMENT since it's enabled by default in Go >=1.6, just use go 1.6 if you want to build outside the container. * Stop using unset/env -u, just avoid adding env variables where needed. * Pass build flags consistently to codecgen. * Let the experimental/ directory be. --- Makefile | 24 +++++++++--------------- experimental/Makefile | 8 ++++---- experimental/demoprobe/Makefile | 11 +++++------ experimental/fixprobe/Makefile | 10 ++++------ experimental/genreport/Makefile | 11 +++++------ 5 files changed, 27 insertions(+), 37 deletions(-) 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 + From 7f5005a13166004f3b30c51881994ce56e0d87d9 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 15 Mar 2016 10:13:58 +0000 Subject: [PATCH 08/10] Bump vendor/github.com/ugorji/go/codec To be able to get rid of GO15VENDOREXPERIMENT https://github.com/ugorji/go/issues/147 --- vendor/github.com/ugorji/go/codec/codecgen/README.md | 1 + vendor/github.com/ugorji/go/codec/codecgen/gen.go | 7 ++++--- vendor/github.com/ugorji/go/codec/gen.go | 8 +++----- vendor/github.com/ugorji/go/codec/gen_15.go | 12 ++++++++++++ vendor/github.com/ugorji/go/codec/gen_16.go | 12 ++++++++++++ vendor/manifest | 2 +- 6 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 vendor/github.com/ugorji/go/codec/gen_15.go create mode 100644 vendor/github.com/ugorji/go/codec/gen_16.go diff --git a/vendor/github.com/ugorji/go/codec/codecgen/README.md b/vendor/github.com/ugorji/go/codec/codecgen/README.md index 3ae8a056f..854b64bfc 100644 --- a/vendor/github.com/ugorji/go/codec/codecgen/README.md +++ b/vendor/github.com/ugorji/go/codec/codecgen/README.md @@ -23,6 +23,7 @@ Usage of codecgen: -c="github.com/ugorji/go/codec": codec path -o="": out file -r=".*": regex for type name to match + -nr="": regex for type name to exclude -rt="": tags for go run -t="": build tag to put in file -u=false: Use unsafe, e.g. to avoid unnecessary allocation on []byte->string diff --git a/vendor/github.com/ugorji/go/codec/codecgen/gen.go b/vendor/github.com/ugorji/go/codec/codecgen/gen.go index f370b4c79..d5e214c37 100644 --- a/vendor/github.com/ugorji/go/codec/codecgen/gen.go +++ b/vendor/github.com/ugorji/go/codec/codecgen/gen.go @@ -82,7 +82,7 @@ func CodecGenTempWrite{{ .RandString }}() { // fout contains Codec(En|De)codeSelf implementations for every type T. // func Generate(outfile, buildTag, codecPkgPath string, uid int64, useUnsafe bool, goRunTag string, - st string, regexName *regexp.Regexp, deleteTempFile bool, infiles ...string) (err error) { + st string, regexName *regexp.Regexp, notRegexName *regexp.Regexp, deleteTempFile bool, infiles ...string) (err error) { // For each file, grab AST, find each type, and write a call to it. if len(infiles) == 0 { return @@ -180,7 +180,7 @@ func Generate(outfile, buildTag, codecPkgPath string, uid int64, useUnsafe bool, // FuncType, InterfaceType, StarExpr (ptr), etc switch td.Type.(type) { case *ast.StructType, *ast.Ident, *ast.MapType, *ast.ArrayType, *ast.ChanType: - if regexName.FindStringIndex(td.Name.Name) != nil { + if regexName.FindStringIndex(td.Name.Name) != nil && notRegexName.FindStringIndex(td.Name.Name) == nil { tv.Types = append(tv.Types, td.Name.Name) } } @@ -259,6 +259,7 @@ func main() { c := flag.String("c", genCodecPath, "codec path") t := flag.String("t", "", "build tag to put in file") r := flag.String("r", ".*", "regex for type name to match") + nr := flag.String("nr", "^$", "regex for type name to exclude") rt := flag.String("rt", "", "tags for go run") st := flag.String("st", "codec,json", "struct tag keys to introspect") x := flag.Bool("x", false, "keep temp file") @@ -266,7 +267,7 @@ func main() { d := flag.Int64("d", 0, "random identifier for use in generated code") flag.Parse() if err := Generate(*o, *t, *c, *d, *u, *rt, *st, - regexp.MustCompile(*r), !*x, flag.Args()...); err != nil { + regexp.MustCompile(*r), regexp.MustCompile(*nr), !*x, flag.Args()...); err != nil { fmt.Fprintf(os.Stderr, "codecgen error: %v\n", err) os.Exit(1) } diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go index 8544f04f6..ac8cc6ddc 100644 --- a/vendor/github.com/ugorji/go/codec/gen.go +++ b/vendor/github.com/ugorji/go/codec/gen.go @@ -12,7 +12,6 @@ import ( "io" "io/ioutil" "math/rand" - "os" "reflect" "regexp" "sort" @@ -126,6 +125,7 @@ var ( genExpectArrayOrMapErr = errors.New("unexpected type. Expecting array/map/slice") genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__") genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`) + genCheckVendor bool ) // genRunner holds some state used during a Gen run. @@ -1626,8 +1626,6 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string { } -var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" - // genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise. // // This handles the misbehaviour that occurs when 1.5-style vendoring is enabled, @@ -1678,7 +1676,7 @@ func genNonPtr(t reflect.Type) reflect.Type { func genTitleCaseName(s string) string { switch s { - case "interface{}": + case "interface{}", "interface {}": return "Intf" default: return strings.ToUpper(s[0:1]) + s[1:] @@ -1781,7 +1779,7 @@ func (x genInternal) FastpathLen() (l int) { func genInternalZeroValue(s string) string { switch s { - case "interface{}": + case "interface{}", "interface {}": return "nil" case "bool": return "false" diff --git a/vendor/github.com/ugorji/go/codec/gen_15.go b/vendor/github.com/ugorji/go/codec/gen_15.go new file mode 100644 index 000000000..ab76c3102 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/gen_15.go @@ -0,0 +1,12 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build go1.5,!go1.6 + +package codec + +import "os" + +func init() { + genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" +} diff --git a/vendor/github.com/ugorji/go/codec/gen_16.go b/vendor/github.com/ugorji/go/codec/gen_16.go new file mode 100644 index 000000000..87c04e2e1 --- /dev/null +++ b/vendor/github.com/ugorji/go/codec/gen_16.go @@ -0,0 +1,12 @@ +// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. +// Use of this source code is governed by a MIT license found in the LICENSE file. + +// +build go1.6 + +package codec + +import "os" + +func init() { + genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0" +} diff --git a/vendor/manifest b/vendor/manifest index 929bc3956..07ed04276 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -796,7 +796,7 @@ { "importpath": "github.com/ugorji/go/codec", "repository": "https://github.com/ugorji/go", - "revision": "03b46f3d7a8e0457836a5ecd906b4961a5815a63", + "revision": "c062049c1793b01a3cc3fe786108edabbaf7756b", "branch": "master", "path": "/codec" }, From 987ccb799254a0b8901e14e8de0e7f6ef9cc1acc Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 15 Mar 2016 10:20:04 +0000 Subject: [PATCH 09/10] Fix typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 389063150..a048fbb1a 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ RUN_FLAGS=-ti BUILD_IN_CONTAINER=true GO_ENV=GOGC=off GO=env $(GO_ENV) go -NO_CROSS_COMP=unset GOOS GOHOST +NO_CROSS_COMP=unset GOOS GOARCH GO_HOST=$(NO_CROSS_COMP); $(GO) WITH_GO_HOST_ENV=$(NO_CROSS_COMP); $(GO_ENV) GO_BUILD_INSTALL_DEPS=-i From 6a62037d303e58094d6eb2acc78242252d10e777 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 15 Mar 2016 12:00:05 +0000 Subject: [PATCH 10/10] Remove full bin directory of codecgen --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a048fbb1a..36892fb5f 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ clean: # $(SUDO) docker rmi $(SCOPE_UI_BUILD_IMAGE) $(SCOPE_BACKEND_BUILD_IMAGE) >/dev/null 2>&1 || true rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \ $(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/app.js docker/weave .pkg \ - $(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin/* + $(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin deps: $(GO) get -u -f -tags $(GO_BUILD_TAGS) \