blob: 8ed55fc17ab86bd1d373c7ed2f796f63764839a7 [file] [log] [blame]
Scott Baker2c0ebda2019-05-06 16:55:47 -07001ifeq ($(GOPATH),)
2$(error Please set your GOPATH)
3endif
4
5VERSION=$(shell cat $(GOPATH)/src/github.com/opencord/cordctl/VERSION)
6GITCOMMIT=$(shell git log --pretty=format:"%h" -n 1)
7GOVERSION=$(shell go version 2>&1 | sed -E 's/.*(go[0-9]+\.[0-9]+\.[0-9]+).*/\1/g')
8OSTYPE=$(shell uname -s | tr A-Z a-z)
9OSARCH=$(shell uname -p | tr A-Z a-z)
10BUILDTIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
11
12LDFLAGS=-ldflags \
13 '-X "github.com/opencord/cordctl/cli/version.Version=$(VERSION)" \
14 -X "github.com/opencord/cordctl/cli/version.GitCommit=$(GITCOMMIT)" \
15 -X "github.com/opencord/cordctl/cli/version.GoVersion=$(GOVERSION)" \
16 -X "github.com/opencord/cordctl/cli/version.Os=$(OSTYPE)" \
17 -X "github.com/opencord/cordctl/cli/version.Arch=$(OSARCH)" \
18 -X "github.com/opencord/cordctl/cli/version.BuildTime=$(BUILDTIME)"' \
19
20help:
21
22build: dependencies
23 go build $(LDFLAGS) cmd/cordctl.go
24
25dependencies:
26 dep ensure
27
28lint: dependencies
29 find $(GOPATH)/src/github.com/opencord/cordctl -name "*.go" -not -path '$(GOPATH)/src/github.com/opencord/cordctl/vendor/*' | xargs gofmt -l
30 go vet ./...
31 dep check
32
33test: dependencies
34 @mkdir -p ./tests/results
35 @go test -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\
36 RETURN=$$? ;\
37 go-junit-report < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\
38 gocover-cobertura < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\
39 exit $$RETURN