-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
434 lines (411 loc) · 10.6 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
PROTOC_GEN_TS_PATH=${HOME}/.npm_modules/bin/protoc-gen-ts
.PHONY: proto
proto: proto-gen tidy
# -I are the import paths, because we're using some plugins, we need to import the gogo protobuf helpers
.PHONY: proto-gen
proto-gen: gen-file gen-util gen-status gen-pubsub gen-admin gen-namesys gen-node gen-replication gen-docs
# builds the static website
.PHONY: build-docs
build-docs:
bundle exec jekyll build
# serve the docs locally, requires properly installing jekyll
.PHONY: serve-docs
serve-docs:
bundle exec jekyll serve
# installs dependencies needed to serve docs locally
.PHONY: install-docs
install-docs:
gem install github-pages
bundle install
# run standard go tooling for better readability
.PHONY: tidy
tidy: imports fmt
go vet ./...
golint ./...
# automatically add missing imports
.PHONY: imports
imports:
find . -type f -name '*.go' -exec goimports -w {} \;
# format code and simplify if possible
.PHONY: fmt
fmt:
find . -type f -name '*.go' -exec gofmt -s -w {} \;
# install supplementary tooling
.PHONY: install
install:
go get -u github.com/gogo/protobuf/protoc-gen-gogoslick
go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
go get -u github.com/gogo/protobuf/protoc-gen-gogofast
go get -u github.com/gogo/protobuf/protoc-gen-gogo
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
go get -u github.com/gogo/protobuf/proto
go get -u github.com/gogo/protobuf/gogoproto
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
npm install -g ts-protoc-gen
npm install -g grpc
npm install -g @grpc/proto-loader
npm install -g grpc-tools
python3 -m pip install grpcio-tools
bash .script/protoc-js.sh
cargo install protobuf-codegen
cargo install grpcio-compiler
# protocol buffer generation targets
gen-file:
# generate golang bindings (file)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/file.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (file)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/file.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (file)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/file.proto
# generate javascript bindings (file)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/file.proto
# generate java bindings (file)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/file.proto
# generate rust bindings (file)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/file.proto
gen-util:
# generate golang bindings (util)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/util.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (util) no grpc bindings for this so --grpc_python_out is omitted
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/util.proto \
--python_out=py
# generate typescript bindings (util)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/util.proto
# generate javascript bindings (util)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/util.proto
# generate java bindings (util)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/util.proto
# generate rust bindings (util)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/util.proto
gen-node:
# generate golang bindings (node)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/node.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (node)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/node.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (node)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/node.proto
# generate javascript bindings (node)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/node.proto
# generate java bindings (node)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/node.proto
# generate rust bindings (node)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/node.proto
gen-status:
# generate golang bindings (status)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/status.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (status)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/status.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (status)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/status.proto
# generate javascript bindings (dag)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/status.proto
# generate java bindings (status)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/status.proto
# generate rust bindings (status)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/status.proto
gen-pubsub:
# generate golang bindings (pubsub)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/pubsub.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (pubsub)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/pubsub.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (pubsub)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/pubsub.proto
# generate javascript bindings (pubsub)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/pubsub.proto
# generate java bindings (pubsub)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/pubsub.proto
# generate rust bindings (pubsub)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/pubsub.proto
gen-admin:
# generate golang bindings (admin)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/admin.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (admin)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/admin.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (admin)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/admin.proto
# generate javascript bindings (dag)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/admin.proto
# generate java bindings (admin)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/admin.proto
# generate rust bindings (admin)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/admin.proto
gen-namesys:
# generate golang bindings (namesys)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/namesys.proto \
--gogofaster_out=plugins=grpc:go
# generate python bindings (namesys)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/namesys.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (namesys)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/namesys.proto
# generate javascript bindings (namesys)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/namesys.proto
# generate java bindings (namesys)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/namesys.proto
# generate rust bindings (namesys)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/namesys.proto
gen-replication:
# generate golang bindings (replication)
protoc \
-I=pb \
-I=${GOPATH}/src \
pb/replication.proto \
--gogofast_out=plugins=grpc:go
# generate python bindings (replication)
python3 -m grpc_tools.protoc \
-I=pb \
-I=${GOPATH}/src \
pb/replication.proto \
--python_out=py \
--grpc_python_out=py
# generate typescript bindings (replication)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
-I=pb \
-I=${GOPATH}/src \
--ts_out=service=grpc-web:ts \
pb/replication.proto
# generate javascript bindings (replication)
protoc \
-I=pb \
-I=${GOPATH}/src \
--js_out=import_style=commonjs,binary:js \
--grpc_out=js \
--plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` \
pb/replication.proto
# generate java bindings (replication)
protoc \
-I=pb \
-I=${GOPATH}/src \
--plugin=protoc-gen-grpc-java=build/protoc-gen-grpc-java \
--grpc-java_out=java \
pb/replication.proto
# generate rust bindings (replication)
protoc \
-I=pb \
-I=${GOPATH}/src \
--rust_out=rs/src \
--grpc_out=rs/src \
--plugin=protoc-gen-grpc=`which grpc_rust_plugin` \
pb/replication.proto
gen-docs:
# generate documentation
protoc \
-I=pb \
--doc_out=doc \
--doc_opt=markdown,PROTO.md \
pb/*.proto