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..36892fb5f 100644 --- a/Makefile +++ b/Makefile @@ -16,17 +16,22 @@ 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 RUN_FLAGS=-ti BUILD_IN_CONTAINER=true -GO ?= env GO15VENDOREXPERIMENT=1 GOGC=off go +GO_ENV=GOGC=off +GO=env $(GO_ENV) go +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 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): @@ -46,16 +51,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 \ @@ -78,12 +82,13 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) false; \ } -%.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))) +%.codecgen.go: $(CODECGEN_EXE) + 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): $(SCOPE_BACKEND_BUILD_UPTODATE) - env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(@D) +$(CODECGEN_EXE): $(CODECGEN_DIR)/*.go + mkdir -p $(@D) + $(GO_HOST) build $(GO_BUILD_FLAGS) -o $@ ./$(CODECGEN_DIR) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @@ -147,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_EXE) + $(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin deps: $(GO) get -u -f -tags $(GO_BUILD_TAGS) \ 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/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 3313b1bf8..4310a7d89 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -790,7 +790,7 @@ { "importpath": "github.com/ugorji/go/codec", "repository": "https://github.com/ugorji/go", - "revision": "03b46f3d7a8e0457836a5ecd906b4961a5815a63", + "revision": "c062049c1793b01a3cc3fe786108edabbaf7756b", "branch": "master", "path": "/codec" },