-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
43 lines (34 loc) · 1.05 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
.DEFAULT: install
install:
go install ./cmd/protoc-gen-go-patch
tools: internal/tools/*.go
go generate --tags tools ./internal/tools
buf-login:
buf registry login buf.build
buf-push:
buf push
go_module = $(shell go list -m)
proto_files = $(sort $(shell find . -name '*.proto'))
proto_includes = \
-I . \
-I $(shell go list -m -f {{.Dir}} google.golang.org/protobuf) \
-I $(shell go list -m -f {{.Dir}} github.com/envoyproxy/protoc-gen-validate) \
protos: $(proto_files)
.PHONY: $(proto_files)
$(proto_files): tools Makefile
# protoc-gen-go
protoc --experimental_allow_proto3_optional \
$(proto_includes) \
--go-patch_out=plugin=go-grpc,paths=import,module=$(go_module):. \
$@
# protoc-gen-go-grpc
protoc --experimental_allow_proto3_optional \
$(proto_includes) \
--go-patch_out=plugin=go,paths=import,module=$(go_module):. \
$@
# protoc-gen-validate
if grep -q validate/validate\.proto $@; then protoc --experimental_allow_proto3_optional \
$(proto_includes) \
--go-patch_out=plugin=validate,paths=source_relative,lang=go:. \
$@ ; \
fi