-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (64 loc) · 3.04 KB
/
Makefile
File metadata and controls
76 lines (64 loc) · 3.04 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
.PHONY: proto test deps mocks
export GOPRIVATE=github.com/anyproto
export PATH:=$(CURDIR)/deps:$(PATH)
all:
@set -e;
@git config core.hooksPath .githooks;
PROTOC=protoc
PROTOC_GEN_GO=deps/protoc-gen-go
PROTOC_GEN_DRPC=deps/protoc-gen-go-drpc
PROTOC_GEN_VTPROTO=deps/protoc-gen-go-vtproto
define generate_proto
@echo "Generating Protobuf for directory: $(1)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \
--go-vtproto_out=. --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_VTPROTO)" \
--go-vtproto_opt=features=marshal+unmarshal+size \
--proto_path=$(1) $(wildcard $(1)/*.proto)
endef
define generate_drpc
@echo "Generating Protobuf for directory: $(1) $(which protoc-gen-go)"
$(PROTOC) \
--go_out=. --plugin protoc-gen-go=$$(which protoc-gen-go) \
--plugin protoc-gen-go-drpc=$(PROTOC_GEN_DRPC) \
--go_opt=$(1) \
--go-vtproto_out=:. --plugin protoc-gen-go-vtproto=$(PROTOC_GEN_VTPROTO) \
--go-vtproto_opt=features=marshal+unmarshal+size \
--go-drpc_out=protolib=github.com/planetscale/vtprotobuf/codec/drpc:. $(wildcard $(2)/*.proto)
endef
proto:
@echo 'Generating protobuf packages (Go)...'
@$(eval P_ACL_RECORDS_PATH_PB := commonspace/object/acl/aclrecordproto)
@$(eval P_ACL_RECORDS_PATH_PB := commonspace/object/acl/aclrecordproto)
@$(eval P_TREE_CHANGES_PATH_PB := commonspace/object/tree/treechangeproto)
@$(eval P_CRYPTO_PATH_PB := util/crypto/cryptoproto)
@$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anyproto/any-sync/$(P_ACL_RECORDS_PATH_PB))
@$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anyproto/any-sync/$(P_TREE_CHANGES_PATH_PB))
$(call generate_proto,$(P_ACL_RECORDS_PATH_PB)/protos)
$(call generate_proto,$(P_TREE_CHANGES_PATH_PB)/protos)
$(call generate_proto,$(P_CRYPTO_PATH_PB)/protos)
$(eval PKGMAP := $$(P_TREE_CHANGES)$(comma)$$(P_ACL_RECORDS))
$(call generate_drpc,$(PKGMAP),commonspace/spacesyncproto/protos)
$(call generate_drpc,$(PKGMAP),commonspace/clientspaceproto/protos)
$(call generate_drpc,$(PKGMAP),commonfile/fileproto/protos)
$(call generate_drpc,$(PKGMAP),net/streampool/testservice/protos)
$(call generate_drpc,$(PKGMAP),net/endtoendtest/testpeer/testproto/protos)
$(call generate_drpc,,net/secureservice/handshake/handshakeproto/protos)
$(call generate_drpc,,net/rpc/limiter/limiterproto/protos)
$(call generate_drpc,$(PKGMAP),coordinator/coordinatorproto/protos)
$(call generate_drpc,,consensus/consensusproto/protos)
$(call generate_drpc,,identityrepo/identityrepoproto/protos)
$(call generate_drpc,,nameservice/nameserviceproto/protos)
$(call generate_drpc,,paymentservice/paymentserviceproto/protos)
deps:
go mod download
go build -o deps storj.io/drpc/cmd/protoc-gen-go-drpc
go build -o deps google.golang.org/protobuf/cmd/protoc-gen-go
go build -o deps github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto
go build -o deps go.uber.org/mock/mockgen
mocks:
echo 'Generating mocks...'
go generate ./...
test:
# TODO: remove GOEXPERIMENT when go 1.25
GOEXPERIMENT=synctest go test ./... --cover