build: Makefile: set GO111MODULE=on for all go commands

This commit is contained in:
Christian Schwarz 2019-10-26 14:53:01 +02:00
parent b0f2c79944
commit e0a25d04ac

View File

@ -13,10 +13,11 @@ ifndef _ZREPL_VERSION
endif endif
endif endif
GO := go GO := go
GO_ENV_VARS := GO111MODULE=on
GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(_ZREPL_VERSION)" GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(_ZREPL_VERSION)"
GO_MOD_READONLY := -mod=readonly GO_MOD_READONLY := -mod=readonly
GO_BUILDFLAGS := $(GO_MOD_READONLY) GO_BUILDFLAGS := $(GO_MOD_READONLY)
GO_BUILD := GO111MODULE=on $(GO) build $(GO_BUILDFLAGS) -v -ldflags $(GO_LDFLAGS) GO_BUILD := $(GO_ENV_VARS) $(GO) build $(GO_BUILDFLAGS) -v -ldflags $(GO_LDFLAGS)
# keep in sync with vet target # keep in sync with vet target
RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64 RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64
@ -29,7 +30,7 @@ THIS_PLATFORM_RELEASE_BIN := $(shell bash -c 'source <($(GO) env) && echo "zrepl
generate: #not part of the build, must do that manually generate: #not part of the build, must do that manually
protoc -I=replication/logic/pdu --go_out=plugins=grpc:replication/logic/pdu replication/logic/pdu/pdu.proto protoc -I=replication/logic/pdu --go_out=plugins=grpc:replication/logic/pdu replication/logic/pdu/pdu.proto
$(GO) generate $(GO_BUILDFLAGS) -x ./... $(GO_ENV_VARS) $(GO) generate $(GO_BUILDFLAGS) -x ./...
format: format:
goimports -srcdir . -local 'github.com/zrepl/zrepl' -w $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go') goimports -srcdir . -local 'github.com/zrepl/zrepl' -w $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go')
@ -41,18 +42,18 @@ build:
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl" $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl"
test: test:
$(GO) test $(GO_BUILDFLAGS) ./... $(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) ./...
# TODO compile the tests for each supported platform # TODO compile the tests for each supported platform
# but `go test -c ./...` is not supported # but `go test -c ./...` is not supported
vet: vet:
$(GO) vet $(GO_BUILDFLAGS) ./... $(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
# for each supported platform to cover conditional compilation # for each supported platform to cover conditional compilation
# (keep in sync with RELEASE_BINS) # (keep in sync with RELEASE_BINS)
GOOS=freebsd GOARCH=amd64 $(GO) vet $(GO_BUILDFLAGS) ./... GOOS=freebsd GOARCH=amd64 $(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
GOOS=linux GOARCH=amd64 $(GO) vet $(GO_BUILDFLAGS) ./... GOOS=linux GOARCH=amd64 $(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
GOOS=linux GOARCH=arm64 $(GO) vet $(GO_BUILDFLAGS) ./... GOOS=linux GOARCH=arm64 $(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
GOOS=darwin GOARCH=amd64 $(GO) vet $(GO_BUILDFLAGS) ./... GOOS=darwin GOARCH=amd64 $(GO_ENV_VARS) $(GO) vet $(GO_BUILDFLAGS) ./...
ZREPL_PLATFORMTEST_POOLNAME := zreplplatformtest ZREPL_PLATFORMTEST_POOLNAME := zreplplatformtest
ZREPL_PLATFORMTEST_IMAGEPATH := /tmp/zreplplatformtest.pool.img ZREPL_PLATFORMTEST_IMAGEPATH := /tmp/zreplplatformtest.pool.img
@ -72,7 +73,7 @@ $(ARTIFACTDIR)/bash_completion: $(RELEASE_BINS)
.PHONY: $(ARTIFACTDIR)/go_version.txt .PHONY: $(ARTIFACTDIR)/go_version.txt
$(ARTIFACTDIR)/go_version.txt: $(ARTIFACTDIR)/go_version.txt:
$(GO) version > $@ $(GO_ENV_VARS) $(GO) version > $@
docs: $(ARTIFACTDIR)/docs docs: $(ARTIFACTDIR)/docs
make -C docs \ make -C docs \