forked from envoyproxy/go-control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (125 loc) · 4.03 KB
/
Makefile
File metadata and controls
161 lines (125 loc) · 4.03 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
.DEFAULT_GOAL := build
#------------------------------------------------------------------------------
# Variables
#------------------------------------------------------------------------------
SHELL := /bin/bash
BINDIR := bin
PKG := github.com/envoyproxy/go-control-plane
# Pure Go sources (not vendored and not generated)
GOFILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GODIRS = $(shell go list -f '{{.Dir}}' ./... \
| grep -vFf <(go list -f '{{.Dir}}' ./vendor/...))
.PHONY: build
build: vendor
@echo "--> building"
@go build ./...
.PHONY: clean
clean:
@echo "--> cleaning compiled objects and binaries"
@go clean -tags netgo -i ./...
@rm -rf $(BINDIR)/*
.PHONY: test
test: vendor
@echo "--> running unit tests"
@go test ./pkg/...
.PHONY: cover
cover:
@echo "--> running coverage tests"
@build/coverage.sh
.PHONY: check
check: format.check vet lint
.PHONY: format
format: tools.goimports
@echo "--> formatting code with 'goimports' tool"
@goimports -local $(PKG) -w -l $(GOFILES)
.PHONY: format.check
format.check: tools.goimports
@echo "--> checking code formatting with 'goimports' tool"
@goimports -local $(PKG) -l $(GOFILES) | sed -e "s/^/\?\t/" | tee >(test -z)
.PHONY: vet
vet: tools.govet
@echo "--> checking code correctness with 'go vet' tool"
@go vet ./...
.PHONY: lint
lint: tools.golint
@echo "--> checking code style with 'golint' tool"
@echo $(GODIRS) | xargs -n 1 golint
#-----------------
#-- integration
#-----------------
.PHONY: $(BINDIR)/test $(BINDIR)/test-linux docker integration integration.ads integration.xds integration.rest integration.docker
$(BINDIR)/test: vendor
@echo "--> building test binary"
@go build -race -o $@ pkg/test/main/main.go
$(BINDIR)/test-linux: vendor
@echo "--> building Linux test binary"
@env GOOS=linux GOARCH=amd64 go build -race -o $@ pkg/test/main/main.go
docker: vendor
@echo "--> building test docker image"
@docker build -t test .
integration: integration.ads integration.xds integration.rest
integration.ads: $(BINDIR)/test
env XDS=ads build/integration.sh
integration.xds: $(BINDIR)/test
env XDS=xds build/integration.sh
integration.rest: $(BINDIR)/test
env XDS=rest build/integration.sh
integration.docker: docker
docker run -it -e "XDS=ads" test -debug
docker run -it -e "XDS=xds" test -debug
docker run -it -e "XDS=rest" test -debug
docker run -it -e "XDS=ads" test -debug -tls
docker run -it -e "XDS=xds" test -debug -tls
docker run -it -e "XDS=rest" test -debug -tls
#-----------------
#-- code generaion
#-----------------
generate: $(BINDIR)/gogofast $(BINDIR)/validate
@echo "--> generating pb.go files"
$(SHELL) build/generate_protos.sh
#------------------
#-- dependencies
#------------------
.PHONY: depend.update depend.install
depend.update: tools.glide
@echo "--> updating dependencies from glide.yaml"
@glide update
depend.install: tools.glide
@echo "--> installing dependencies from glide.lock "
@glide install
vendor:
@echo "--> installing dependencies from glide.lock "
@glide install
$(BINDIR):
@mkdir -p $(BINDIR)
#---------------
#-- 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 -u golang.org/x/lint/golint; \
fi
tools.glide:
@command -v glide >/dev/null ; if [ $$? -ne 0 ]; then \
echo "--> installing glide"; \
curl https://glide.sh/get | sh; \
fi
$(BINDIR)/gogofast: vendor
@echo "--> building $@"
@go build -o $@ vendor/github.com/gogo/protobuf/protoc-gen-gogofast/main.go
$(BINDIR)/validate: vendor
@echo "--> building $@"
@go build -o $@ vendor/github.com/lyft/protoc-gen-validate/main.go