Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Ldflags (#100)
Browse files Browse the repository at this point in the history
* Build hash and version can be passed as variables

* Version by default comes from the last tag

* Make the advacned vet with the shadow dependency optional

Brew dont allows to execute go vet so better to avoid using it

* Remove spaces for ifeq in the makefile
  • Loading branch information
ethervoid authored and mgdelacroix committed Jan 9, 2020
1 parent 339327e commit c330b36
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
.PHONY: vendor docs mocks
GO_PACKAGES=$(shell go list ./...)
GO ?= $(shell command -v go 2> /dev/null)
BUILD_HASH = $(shell git rev-parse HEAD)
BUILD_HASH ?= $(shell git rev-parse HEAD)
BUILD_VERSION ?= $(shell git ls-remote --tags --refs --sort="v:refname" git://github.com/mattermost/mmctl | tail -n1 | sed 's/.*\///')
# Needed to avoid install shadow in brew which is not permitted
ADVANCED_VET ?= TRUE

LDFLAGS += -X "github.com/mattermost/mmctl/commands.BuildHash=$(BUILD_HASH)"
LDFLAGS += -X "github.com/mattermost/mmctl/commands.Version=$(BUILD_VERSION)"

all: build

Expand Down Expand Up @@ -48,9 +52,11 @@ gofmt:

govet:
@echo Running govet
env GO111MODULE=off $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
$(GO) vet $(GO_PACKAGES)
ifeq ($(ADVANCED_VET), TRUE)
env GO111MODULE=off $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
$(GO) vet -vettool=$(GOPATH)/bin/shadow $(GO_PACKAGES)
endif
@echo Govet success

test: test-unit
Expand Down

0 comments on commit c330b36

Please sign in to comment.