1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00

GOCC implementation & fix in make & build scripts

The usage of a native 'go' command has been replaced with a make &
environment variable $GOCC. This enables building with multiple go
versions on a single machine as documented:
  * https://golang.org/doc/install#extra_versions

This enables the usage of:
```bash
$ make install
$ # OR
$ GOCC=go1.12.3 make install
$ # OR
$ GOCC=go1.12.4 make install
```
And the build and test tools now pick up on this change

 On branch go-version-check
 Changes to be committed:
	modified:   Rules.mk
	modified:   bin/check_go_version
	modified:   bin/dist_get
	modified:   bin/maketarball.sh
	modified:   coverage/Rules.mk
	modified:   mk/golang.mk
	modified:   mk/tarball.mk
License: MIT
Signed-off-by: Chris Buesser <christopher.buesser@gmail.com>
This commit is contained in:
Christopher Buesser
2019-04-30 21:22:43 -04:00
parent c1bc202f41
commit f31dd2aae6
7 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,7 @@
include mk/header.mk
GOCC ?= go
$(d)/coverage_deps: $$(DEPS_GO)
rm -rf $(@D)/unitcover && mkdir $(@D)/unitcover
rm -rf $(@D)/sharnesscover && mkdir $(@D)/sharnesscover
@ -11,16 +13,16 @@ endif
.PHONY: $(d)/coverage_deps
# unit tests coverage
UTESTS_$(d) := $(shell go list -f '{{if (len .TestGoFiles)}}{{.ImportPath}}{{end}}' $(go-flags-with-tags) ./...)
UTESTS_$(d) += $(shell go list -f '{{if (len .XTestGoFiles)}}{{.ImportPath}}{{end}}' $(go-flags-with-tags) ./... | grep -v go-ipfs/vendor | grep -v go-ipfs/Godeps)
UTESTS_$(d) := $(shell $(GOCC) list -f '{{if (len .TestGoFiles)}}{{.ImportPath}}{{end}}' $(go-flags-with-tags) ./...)
UTESTS_$(d) += $(shell $(GOCC) list -f '{{if (len .XTestGoFiles)}}{{.ImportPath}}{{end}}' $(go-flags-with-tags) ./... | grep -v go-ipfs/vendor | grep -v go-ipfs/Godeps)
UCOVER_$(d) := $(addsuffix .coverprofile,$(addprefix $(d)/unitcover/, $(subst /,_,$(UTESTS_$(d)))))
$(UCOVER_$(d)): $(d)/coverage_deps ALWAYS
$(eval TMP_PKG := $(subst _,/,$(basename $(@F))))
$(eval TMP_DEPS := $(shell go list -f '{{range .Deps}}{{.}} {{end}}' $(go-flags-with-tags) $(TMP_PKG) | sed 's/ /\n/g' | grep ipfs/go-ipfs) $(TMP_PKG))
$(eval TMP_DEPS := $(shell $(GOCC) list -f '{{range .Deps}}{{.}} {{end}}' $(go-flags-with-tags) $(TMP_PKG) | sed 's/ /\n/g' | grep ipfs/go-ipfs) $(TMP_PKG))
$(eval TMP_DEPS_LIST := $(call join-with,$(comma),$(TMP_DEPS)))
go test $(go-flags-with-tags) $(GOTFLAGS) -v -covermode=atomic -json -coverpkg=$(TMP_DEPS_LIST) -coverprofile=$@ $(TMP_PKG) | tee -a test/unit/gotest.json
$(GOCC) test $(go-flags-with-tags) $(GOTFLAGS) -v -covermode=atomic -json -coverpkg=$(TMP_DEPS_LIST) -coverprofile=$@ $(TMP_PKG) | tee -a test/unit/gotest.json
$(d)/unit_tests.coverprofile: $(UCOVER_$(d))