diff --git a/Rules.mk b/Rules.mk index d28e3e0f4..f4f739365 100644 --- a/Rules.mk +++ b/Rules.mk @@ -4,6 +4,7 @@ COVERAGE := DISTCLEAN := TEST := TEST_SHORT := +GOCC ?= go all: help # all has to be first defined target .PHONY: all @@ -104,7 +105,7 @@ install_unsupported: install .PHONY: install_unsupported uninstall: - go clean -i ./cmd/ipfs + $(GOCC) clean -i ./cmd/ipfs .PHONY: uninstall help: diff --git a/bin/check_go_version b/bin/check_go_version index 557c9d974..0c513b5e9 100755 --- a/bin/check_go_version +++ b/bin/check_go_version @@ -31,12 +31,14 @@ PREFIX=$(expr "$0" : "\(.*\/\)") || PREFIX='./' # Check that the go binary exist and is in the path -type go >/dev/null 2>&1 || die_upgrade "go is not installed or not in the PATH!" +GOCC=${GOCC="go"} + +type ${GOCC} >/dev/null 2>&1 || die_upgrade "go is not installed or not in the PATH!" # Check the go binary version -VERS_STR=$(go version 2>&1) || die "'go version' failed with output: $VERS_STR" +VERS_STR=$(${GOCC} version 2>&1) || die "'go version' failed with output: $VERS_STR" GO_CUR_VERSION=$(expr "$VERS_STR" : ".*go version go\([^ ]*\) .*") || die "Invalid 'go version' output: $VERS_STR" -check_at_least_version "$GO_MIN_VERSION" "$GO_CUR_VERSION" "go" +check_at_least_version "$GO_MIN_VERSION" "$GO_CUR_VERSION" "${GOCC}" diff --git a/bin/dist_get b/bin/dist_get index 25a22b8a3..39320443a 100755 --- a/bin/dist_get +++ b/bin/dist_get @@ -1,5 +1,7 @@ #!/bin/sh +GOCC=${GOCC=go} + die() { echo "$@" >&2 exit 1 @@ -99,7 +101,7 @@ get_go_vars() { if [ ! -z "$GOOS" ] && [ ! -z "$GOARCH" ]; then printf "%s-%s" "$GOOS" "$GOARCH" elif have_binary go; then - printf "%s-%s" "$(go env GOOS)" "$(go env GOARCH)" + printf "%s-%s" "$($GOCC env GOOS)" "$($GOCC env GOARCH)" else die "no way of determining system GOOS and GOARCH\nPlease manually set GOOS and GOARCH then retry." fi diff --git a/bin/maketarball.sh b/bin/maketarball.sh index 2485e5c53..563091ecd 100755 --- a/bin/maketarball.sh +++ b/bin/maketarball.sh @@ -11,11 +11,13 @@ if ! [[ "$OUTPUT" = /* ]]; then OUTPUT="$PWD/$OUTPUT" fi +GOCC=${GOCC=go} + TMPDIR="$(mktemp -d)" cp -r . "$TMPDIR" ( cd "$TMPDIR" && echo $PWD && - go mod vendor && + $GOCC mod vendor && (git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || true) > .tarball && chmod -R u=rwX,go=rX "$TMPDIR" # normalize permissions tar -czf "$OUTPUT" --exclude="./.git" . diff --git a/coverage/Rules.mk b/coverage/Rules.mk index fdd4f9af6..a466f5358 100644 --- a/coverage/Rules.mk +++ b/coverage/Rules.mk @@ -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)) diff --git a/mk/golang.mk b/mk/golang.mk index e229023cd..7d1857d7c 100644 --- a/mk/golang.mk +++ b/mk/golang.mk @@ -73,7 +73,7 @@ test_go_megacheck: test_go: $(TEST_GO) check_go_version: - @go version + @$(GOCC) version bin/check_go_version $(GO_MIN_VERSION) .PHONY: check_go_version DEPS_GO += check_go_version diff --git a/mk/tarball.mk b/mk/tarball.mk index 0c72988d1..8863528c3 100644 --- a/mk/tarball.mk +++ b/mk/tarball.mk @@ -8,6 +8,7 @@ tarball-is:=1 git-hash:=$(shell cat .tarball) endif +GOCC ?= go go-ipfs-source.tar.gz: distclean - bin/maketarball.sh $@ + GOCC=$(GOCC) bin/maketarball.sh $@