-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
284 lines (222 loc) · 7.28 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
SRCROOT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
BUILDPATH = $(SRCROOT)/build
COVEROUT=$(SRCROOT)/cover.out
COVERTMP=/tmp/cover.out
AT = cd $(SRCROOT)
RM = rm -fv
GOBUILD = go build -v
GOFMTCHECK = test -z `gofmt -s -d *.go | tee /dev/stderr`
GOTEST = go test -v
COVER = $(GOTEST) -coverprofile=$(COVERTMP) -covermode=atomic
JOINCOVER = cat $(COVERTMP) >> $(COVEROUT)
GOTESTRACE = $(COVER) -race && $(JOINCOVER)
GOTESTINTEGRACE = $(COVER) -race -coverpkg github.com/infobloxopen/themis/pdp,github.com/infobloxopen/themis/pdp/ast,github.com/infobloxopen/themis/pdp/ast/yast,github.com/infobloxopen/themis/pdp/ast/jast && $(JOINCOVER)
GOBENCH = $(GOTEST) -run=\^\$$ -bench=
GOBENCHALL = $(GOBENCH).
.PHONY: all
all: fmt build test bench
.PHONY: build-dir
build-dir:
mkdir -p $(BUILDPATH)
.PHONY: bootstrap
bootstrap: build-dir
.PHONY: vendor
vendor:
GO111MODULE=on go mod vendor
GO111MODULE=on go mod tidy
.PHONY: clean
clean:
@$(RM) $(COVEROUT)
@$(RM) $(BUILDPATH)
.PHONY: fmt
fmt: fmt-pdp fmt-pdp-yast fmt-pdp-jast fmt-pdp-jcon fmt-pdp-itests fmt-local-selector fmt-pip-selector fmt-pdpctrl-client fmt-papcli fmt-pep fmt-pepcli fmt-pepcli-requests fmt-pepcli-test fmt-pepcli-perf fmt-pdpserver-pkg fmt-pdpserver fmt-pip-server fmt-pip-client fmt-pip-gen fmt-pip-genpkg fmt-pipjcon fmt-pipcli fmt-pipcli-global fmt-pipcli-subflags fmt-pipcli-test fmt-pipcli-perf fmt-egen
.PHONY: build
build: build-dir build-pepcli build-papcli build-pdpserver build-egen build-pip-gen build-pipjcon build-pipcli
.PHONY: test
test: cover-out test-pdp test-pdp-integration test-pdp-yast test-pdp-jast test-pdp-jcon test-local-selector test-pip-selector test-pep test-pip-server test-pip-client test-pip-genpkg
.PHONY: bench
bench: bench-pep bench-pip-server bench-pip-client bench-pdpserver-pkg
.PHONY: cover-out
cover-out:
echo > $(COVEROUT)
# Per package format targets
.PHONY: fmt-pdp
fmt-pdp:
@echo "Checking PDP format..."
@$(AT)/pdp && $(GOFMTCHECK)
.PHONY: fmt-pdp-yast
fmt-pdp-yast:
@echo "Checking PDP YAST format..."
@$(AT)/pdp/ast/yast && $(GOFMTCHECK)
.PHONY: fmt-pdp-jast
fmt-pdp-jast:
@echo "Checking PDP JAST format..."
@$(AT)/pdp/ast/jast && $(GOFMTCHECK)
.PHONY: fmt-pdp-jcon
fmt-pdp-jcon:
@echo "Checking PDP JCon format..."
@$(AT)/pdp/jcon && $(GOFMTCHECK)
.PHONY: fmt-pdp-itests
fmt-pdp-itests:
@echo "Checking PDP integration tests format..."
@$(AT)/pdp/integration_tests && $(GOFMTCHECK)
.PHONY: fmt-local-selector
fmt-local-selector:
@echo "Checking PDP local selector format..."
@$(AT)/pdp/selector/local && $(GOFMTCHECK)
.PHONY: fmt-pip-selector
fmt-pip-selector:
@echo "Checking PDP PIP selector format..."
@$(AT)/pdp/selector/pip && $(GOFMTCHECK)
.PHONY: fmt-pdpctrl-client
fmt-pdpctrl-client:
@echo "Checking PDP control client library format..."
@$(AT)/pdpctrl-client && $(GOFMTCHECK)
.PHONY: fmt-papcli
fmt-papcli:
@echo "Checking PAP CLI format..."
@$(AT)/papcli && $(GOFMTCHECK)
.PHONY: fmt-pep
fmt-pep:
@echo "Checking PEP client library format..."
@$(AT)/pep && $(GOFMTCHECK)
.PHONY: fmt-pepcli
fmt-pepcli:
@echo "Checking PEP CLI format..."
@$(AT)/pepcli && $(GOFMTCHECK)
.PHONY: fmt-pepcli-requests
fmt-pepcli-requests:
@echo "Checking PEP CLI requests package format..."
@$(AT)/pepcli/requests && $(GOFMTCHECK)
.PHONY: fmt-pepcli-test
fmt-pepcli-test:
@echo "Checking PEP CLI test package format..."
@$(AT)/pepcli/test && $(GOFMTCHECK)
.PHONY: fmt-pepcli-perf
fmt-pepcli-perf:
@echo "Checking PEP CLI perf package format..."
@$(AT)/pepcli/perf && $(GOFMTCHECK)
.PHONY: fmt-pdpserver-pkg
fmt-pdpserver-pkg:
@echo "Checking PDP server package format..."
@$(AT)/pdpserver/server && $(GOFMTCHECK)
.PHONY: fmt-pdpserver
fmt-pdpserver:
@echo "Checking PDP server format..."
@$(AT)/pdpserver && $(GOFMTCHECK)
.PHONY: fmt-pip-server
fmt-pip-server:
@echo "Checking PIP server package format..."
@$(AT)/pip/server && $(GOFMTCHECK)
.PHONY: fmt-pip-client
fmt-pip-client:
@echo "Checking PIP client package format..."
@$(AT)/pip/client && $(GOFMTCHECK)
.PHONY: fmt-pip-gen
fmt-pip-gen:
@echo "Checking PIP handler generator format..."
@$(AT)/pip/mkpiphandler && $(GOFMTCHECK)
.PHONY: fmt-pip-genpkg
fmt-pip-genpkg:
@echo "Checking PIP handler generator package format..."
@$(AT)/pip/mkpiphandler/pkg && $(GOFMTCHECK)
.PHONY: fmt-pipjcon
fmt-pipjcon:
@echo "Checking PIP JCon server format..."
@$(AT)/pip/pipjcon && $(GOFMTCHECK)
.PHONY: fmt-pipcli
fmt-pipcli:
@echo "Checking PIP CLI format..."
@$(AT)/pip/pipcli && $(GOFMTCHECK)
.PHONY: fmt-pipcli-global
fmt-pipcli-global:
@echo "Checking PIP CLI global options package format..."
@$(AT)/pip/pipcli/global && $(GOFMTCHECK)
.PHONY: fmt-pipcli-subflags
fmt-pipcli-subflags:
@echo "Checking PIP CLI command flags package format..."
@$(AT)/pip/pipcli/subflags && $(GOFMTCHECK)
.PHONY: fmt-pipcli-test
fmt-pipcli-test:
@echo "Checking PIP CLI test command package format..."
@$(AT)/pip/pipcli/test && $(GOFMTCHECK)
.PHONY: fmt-pipcli-perf
fmt-pipcli-perf:
@echo "Checking PIP CLI perf command package format..."
@$(AT)/pip/pipcli/perf && $(GOFMTCHECK)
.PHONY: fmt-egen
fmt-egen:
@echo "Checking EGen format..."
@$(AT)/egen && $(GOFMTCHECK)
.PHONY: linter
linter:
go get -u github.com/alecthomas/gometalinter
gometalinter --install golint
gometalinter --deadline=1m --disable-all --enable=gofmt --enable=golint --enable=vet --exclude=^vendor/ --exclude=^pb/ ./...
# Per package build targets
.PHONY: build-pepcli
build-pepcli: build-dir
$(AT)/pepcli && $(GOBUILD) -o $(BUILDPATH)/pepcli
.PHONY: build-papcli
build-papcli: build-dir
$(AT)/papcli && $(GOBUILD) -o $(BUILDPATH)/papcli
.PHONY: build-pdpserver
build-pdpserver: build-dir
$(AT)/pdpserver && $(GOBUILD) -o $(BUILDPATH)/pdpserver
.PHONY: build-egen
build-egen: build-dir
$(AT)/egen && $(GOBUILD) -o $(BUILDPATH)/egen
.PHONY: build-pip-gen
build-pip-gen: build-dir
$(AT)/pip/mkpiphandler && $(GOBUILD) -o $(BUILDPATH)/mkpiphandler
.PHONY: build-pipjcon
build-pipjcon: build-dir
$(AT)/pip/pipjcon && $(GOBUILD) -o $(BUILDPATH)/pipjcon
.PHONY: build-pipcli
build-pipcli: build-dir
$(AT)/pip/pipcli && $(GOBUILD) -o $(BUILDPATH)/pipcli
.PHONY: test-pdp
test-pdp: cover-out
$(AT)/pdp && $(GOTESTRACE)
.PHONY: test-pdp-integration
test-pdp-integration: cover-out
$(AT)/pdp/integration_tests && $(GOTESTINTEGRACE)
.PHONY: test-pdp-yast
test-pdp-yast: cover-out
$(AT)/pdp/ast/yast && $(GOTESTRACE)
.PHONY: test-pdp-jast
test-pdp-jast: cover-out
$(AT)/pdp/ast/jast && $(GOTESTRACE)
.PHONY: test-pdp-jcon
test-pdp-jcon: cover-out
$(AT)/pdp/jcon && $(GOTESTRACE)
.PHONY: test-local-selector
test-local-selector: cover-out
$(AT)/pdp/selector/local && $(GOTESTRACE)
.PHONY: test-pip-selector
test-pip-selector: cover-out
$(AT)/pdp/selector/pip && $(GOTESTRACE)
.PHONY: test-pep
test-pep: build-pdpserver cover-out
$(AT)/pep && $(GOTESTRACE)
.PHONY: test-pip-server
test-pip-server:
$(AT)/pip/server && $(GOTESTRACE)
.PHONY: test-pip-client
test-pip-client:
$(AT)/pip/client && $(GOTESTRACE)
.PHONY: test-pip-genpkg
test-pip-genpkg:
$(AT)/pip/mkpiphandler/pkg && $(GOTESTRACE)
.PHONY: bench-pep
bench-pep: build-pdpserver
$(AT)/pep && $(GOBENCHALL)
.PHONY: bench-pip-server
bench-pip-server:
$(AT)/pip/server && $(GOBENCHALL)
.PHONY: bench-pip-client
bench-pip-client:
$(AT)/pip/client && $(GOBENCHALL)
.PHONY: bench-pdpserver-pkg
bench-pdpserver-pkg:
$(AT)/pdpserver/server && $(GOBENCHALL)