forked from envoyproxy/go-control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (93 loc) · 2.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
.DEFAULT_GOAL := build
#------------------------------------------------------------------------------
# Variables
#------------------------------------------------------------------------------
SHELL := /bin/bash
BINDIR := bin
DOCKERDIR := docker
RELEASEDIR := release
OUTPUT_NAME := go-control-plane
GOHOSTOS := $(shell go env GOHOSTOS)
ifndef GOOS
GOOS := $(GOHOSTOS)
endif
ifndef GOARCH
GOARCH := $(shell go env GOHOSTARCH)
endif
GOFILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./api/*")
GODIRS = $(shell go list -f '{{.Dir}}' ./... \
| grep -vFf <(go list -f '{{.Dir}}' ./vendor/...) \
| grep -vFf <(go list -f '{{.Dir}}' ./api/...))
GOPKGS = $(shell go list ./... \
| grep -vFf <(go list ./vendor/...) \
| grep -vFf <(go list ./api/...))
APP_VER := $(shell git describe --always 2> /dev/null || echo "unknown")
.PHONY: build
build:
@go build ./...
clean:
@echo "--> cleaning compiled objects and binaries"
@go clean -tags netgo -i $(GOPKGS)
@rm -rf $(BINDIR)/*
@rm -rf $(RELEASEDIR)/*
.PHONY: test
test:
@echo "--> running unit tests"
@go test -v $(GOPKGS)
.PHONY: cover
cover:
@echo "--> running coverage tests"
@go test -race -cover $(GOPKGS)
.PHONY: check
check: format.check vet lint
format: tools.goimports
@echo "--> formatting code with 'goimports' tool"
@goimports -w -l $(GOFILES)
format.check: tools.goimports
@echo "--> checking code formatting with 'goimports' tool"
@goimports -l $(GOFILES) | sed -e "s/^/\?\t/" | tee >(test -z)
vet: tools.govet
@echo "--> checking code correctness with 'go vet' tool"
@go vet $(GOPKGS)
lint: tools.golint
@echo "--> checking code style with 'golint' tool"
@echo $(GODIRS) | xargs -n 1 golint
generate: depend.install
@echo "--> generating pb.go files"
$(SHELL) generate_protos.sh > generate_protos.log 2>&1
@cat generate_protos.log
#------------------
#-- dependencies
#------------------
.PHONY: depend.update depend.install
depend.update: tools.glide
@echo "--> updating dependencies from glide.yaml"
@glide update --strip-vendor
depend.install: tools.glide
@echo "--> installing dependencies from glide.lock "
@glide install --strip-vendor
#---------------
#-- tools
#---------------
.PHONY: tools tools.glide tools.goimports tools.golint tools.govet
tools: tools.glide tools.goimports tools.golint tools.govet
tools.goimports:
@command -v goimports >/dev/null ; if [ $$? -ne 0 ]; then \
echo "--> installing goimports"; \
go get golang.org/x/tools/cmd/goimports; \
fi
tools.govet:
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
echo "--> installing govet"; \
go get golang.org/x/tools/cmd/vet; \
fi
tools.golint:
@command -v golint >/dev/null ; if [ $$? -ne 0 ]; then \
echo "--> installing golint"; \
go get github.com/golang/lint/golint; \
fi
tools.glide:
@command -v glide >/dev/null ; if [ $$? -ne 0 ]; then \
echo "--> installing glide"; \
curl https://glide.sh/get | sh; \
fi