Skip to content

Commit 4c59cd1

Browse files
authored
Add support for protos in chasm libs (#8182)
## What changed? Added support for defining protos in chasm libs. ## Why? Keep everything local to the library. ## How did you test it? - [x] built - [x] run locally and tested manually
1 parent 08e2dfd commit 4c59cd1

File tree

14 files changed

+496
-65
lines changed

14 files changed

+496
-65
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
/tctl*
2525
/tdbg
2626

27-
# proto image
27+
# proto images
2828
/proto/image.bin
29+
/proto/chasm.bin
2930
# api+google proto dependencies
3031
/proto/api.binpb
3132

@@ -37,3 +38,5 @@
3738

3839
# Git SPR: https://github.com/ejoffe/spr
3940
.spr.yml
41+
42+
/proto.tmp

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ endef
100100

101101
PROTO_ROOT := proto
102102
PROTO_FILES = $(shell find ./$(PROTO_ROOT)/internal -name "*.proto")
103+
CHASM_PROTO_FILES = $(shell find ./chasm/lib -name "*.proto")
103104
PROTO_DIRS = $(sort $(dir $(PROTO_FILES)))
104105
API_BINPB := $(PROTO_ROOT)/api.binpb
105106
# Note: If you change the value of INTERNAL_BINPB, you'll have to add logic to
106107
# develop/buf-breaking.sh to handle the old and new values at once.
107108
INTERNAL_BINPB := $(PROTO_ROOT)/image.bin
109+
CHASM_BINPB := $(PROTO_ROOT)/chasm.bin
108110
PROTO_OUT := api
109111

110112
ALL_SRC := $(shell find . -name "*.go")
@@ -296,11 +298,20 @@ $(INTERNAL_BINPB): $(API_BINPB) $(PROTO_FILES)
296298
@printf $(COLOR) "Generate proto image..."
297299
@protoc --descriptor_set_in=$(API_BINPB) -I=$(PROTO_ROOT)/internal $(PROTO_FILES) -o $@
298300

301+
$(CHASM_BINPB): $(API_BINPB) $(INTERNAL_BINPB) $(CHASM_PROTO_FILES)
302+
@printf $(COLOR) "Generate CHASM proto image..."
303+
@protoc --descriptor_set_in=$(API_BINPB):$(INTERNAL_BINPB) -I=. $(CHASM_PROTO_FILES) -o $@
304+
299305
protoc: $(PROTOGEN) $(MOCKGEN) $(GOIMPORTS) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_HELPERS) $(API_BINPB)
300-
@env \
301-
PROTOGEN=$(PROTOGEN) MOCKGEN=$(MOCKGEN) GOIMPORTS=$(GOIMPORTS) \
302-
API_BINPB=$(API_BINPB) PROTO_ROOT=$(PROTO_ROOT) PROTO_OUT=$(PROTO_OUT) \
303-
./develop/protoc.sh
306+
@go run ./cmd/tools/protogen \
307+
-root=$(ROOT) \
308+
-proto-out=$(PROTO_OUT) \
309+
-proto-root=$(PROTO_ROOT) \
310+
-protogen=$(PROTOGEN) \
311+
-api-binpb=$(API_BINPB) \
312+
-goimports=$(GOIMPORTS) \
313+
-mockgen=$(MOCKGEN) \
314+
$(PROTO_DIRS)
304315

305316
proto-codegen:
306317
@printf $(COLOR) "Generate service clients..."
@@ -368,14 +379,16 @@ lint-api: $(API_LINTER) $(API_BINPB)
368379
@printf $(COLOR) "Linting proto API..."
369380
$(call silent_exec, $(API_LINTER) --set-exit-status -I=$(PROTO_ROOT)/internal --descriptor-set-in $(API_BINPB) --config=$(PROTO_ROOT)/api-linter.yaml $(PROTO_FILES))
370381

371-
lint-protos: $(BUF) $(INTERNAL_BINPB)
382+
lint-protos: $(BUF) $(INTERNAL_BINPB) $(CHASM_BINPB)
372383
@printf $(COLOR) "Linting proto definitions..."
373384
@$(BUF) lint $(INTERNAL_BINPB)
385+
@$(BUF) lint --config chasm/lib/buf.yaml $(CHASM_BINPB)
374386

375387
# Edit proto/internal/buf.yaml to exclude specific files from this check.
388+
# TODO: buf breaking check for CHASM protos.
376389
buf-breaking: $(BUF) $(API_BINPB) $(INTERNAL_BINPB)
377390
@printf $(COLOR) "Run buf breaking proto changes check..."
378-
@env BUF=$(BUF) API_BINPB=$(API_BINPB) INTERNAL_BINPB=$(INTERNAL_BINPB) MAIN_BRANCH=$(MAIN_BRANCH) \
391+
@env BUF=$(BUF) API_BINPB=$(API_BINPB) INTERNAL_BINPB=$(INTERNAL_BINPB) CHASM_BINPB=$(CHASM_BINPB) MAIN_BRANCH=$(MAIN_BRANCH) \
379392
./develop/buf-breaking.sh
380393

381394
shell-check:

api/adminservicemock/v1/service.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/adminservicemock/v1/service_grpc.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/historyservicemock/v1/service.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/historyservicemock/v1/service_grpc.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/matchingservicemock/v1/service.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/matchingservicemock/v1/service_grpc.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/testservicemock/v1/service.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/testservicemock/v1/service_grpc.pb.mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)