Update Makefile.common to support libraries

Specifically tsdb and client_golang that don't use vendoring.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2018-10-29 10:14:22 +01:00
parent 790876da60
commit be68fb0f30
1 changed files with 12 additions and 8 deletions

View File

@ -30,17 +30,19 @@ GOFMT ?= $(GO)fmt
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
GOOPTS ?= GOOPTS ?=
ifneq (,$(wildcard go.mod)) ifneq (,$(wildcard go.mod))
ifeq ($(shell $(GO) version | grep -E 'go1\.(10|[0-9])\.'),) ifeq ($(shell $(GO) version | grep -E 'go1\.(10|[0-9])\.'),)
# Always use the local vendor/ directory to satisfy the dependencies. ifneq (,$(wildcard vendor))
GOOPTS := $(GOOPTS) -mod=vendor # Always use the local vendor/ directory to satisfy the dependencies.
# Enable module support forcibly just in case the directory is inside GOPATH (and Travis CI). GOOPTS := $(GOOPTS) -mod=vendor
GO111MODULE := on endif
# Enable module support forcibly just in case the directory is inside GOPATH (and Travis CI).
GO111MODULE := on
unexport GOVENDOR unexport GOVENDOR
else else
$(warning This repository requires Go >= 1.11 because of Go modules) $(warning This repository requires Go >= 1.11 because of Go modules)
$(warning Some recipes may not work as expected as the current Go runtime is '$(shell $(GO) version)') $(warning Some recipes may not work as expected as the current Go runtime is '$(shell $(GO) version)')
endif endif
else else
# This repository isn't using Go modules (yet). # This repository isn't using Go modules (yet).
GOVENDOR := $(FIRST_GOPATH)/bin/govendor GOVENDOR := $(FIRST_GOPATH)/bin/govendor
@ -123,10 +125,12 @@ else
@echo ">> running check for unused/missing packages in go.mod" @echo ">> running check for unused/missing packages in go.mod"
GO111MODULE=$(GO111MODULE) $(GO) mod tidy GO111MODULE=$(GO111MODULE) $(GO) mod tidy
@git diff --exit-code -- go.sum go.mod @git diff --exit-code -- go.sum go.mod
ifneq (,$(wildcard vendor))
@echo ">> running check for unused packages in vendor/" @echo ">> running check for unused packages in vendor/"
GO111MODULE=$(GO111MODULE) $(GO) mod vendor GO111MODULE=$(GO111MODULE) $(GO) mod vendor
@git diff --exit-code -- go.sum go.mod vendor/ @git diff --exit-code -- go.sum go.mod vendor/
endif endif
endif
.PHONY: common-build .PHONY: common-build
common-build: promu common-build: promu