@@ -26,6 +26,11 @@ YAMLFMT_VERSION ?= v0.16.0
2626# goimports version for Go formatting + import fixing
2727GOIMPORTS_VERSION ?= v0.33.0
2828
29+ # Proto packages: <domain>/<service> dirs whose protopb/ holds the generated
30+ # stubs. Each is generated by Bazel into bazel-bin/tool/proto/<domain>_<service>/
31+ # (the out_dir convention in tool/proto/BUILD.bazel) and copied back here.
32+ PROTO_PACKAGES = submitqueue/gateway submitqueue/orchestrator stovepipe/gateway stovepipe/orchestrator
33+
2934# Set REPO_ROOT for docker-compose
3035export REPO_ROOT := $(shell pwd)
3136
@@ -106,10 +111,7 @@ clean: ## Clean generated files and binaries
106111
107112clean-proto : # # Clean generated proto files
108113 @echo " Cleaning generated proto files..."
109- @rm -rf submitqueue/gateway/protopb/* .pb.go
110- @rm -rf submitqueue/orchestrator/protopb/* .pb.go
111- @rm -rf stovepipe/gateway/protopb/* .pb.go
112- @rm -rf stovepipe/orchestrator/protopb/* .pb.go
114+ @rm -f $(foreach p,$(PROTO_PACKAGES ) ,$(p ) /protopb/* .pb.go $(p ) /protopb/* .pb.yarpc.go)
113115 @echo " Proto clean complete!"
114116
115117deps : tidy-go # # Download and tidy Go dependencies
@@ -338,23 +340,15 @@ mocks: ## Generate mock files using mockgen
338340 @echo " Mocks generated successfully!"
339341
340342proto : # # Generate protobuf files from .proto definitions
341- @echo " Generating protobuf files with protoc..."
342- @protoc --go_out=submitqueue/gateway/protopb --go_opt=paths=source_relative \
343- --go-grpc_out=submitqueue/gateway/protopb --go-grpc_opt=paths=source_relative \
344- --yarpc-go_out=submitqueue/gateway/protopb --yarpc-go_opt=paths=source_relative \
345- --proto_path=submitqueue/gateway/proto submitqueue/gateway/proto/gateway.proto
346- @protoc --go_out=submitqueue/orchestrator/protopb --go_opt=paths=source_relative \
347- --go-grpc_out=submitqueue/orchestrator/protopb --go-grpc_opt=paths=source_relative \
348- --yarpc-go_out=submitqueue/orchestrator/protopb --yarpc-go_opt=paths=source_relative \
349- --proto_path=submitqueue/orchestrator/proto submitqueue/orchestrator/proto/orchestrator.proto
350- @protoc --go_out=stovepipe/gateway/protopb --go_opt=paths=source_relative \
351- --go-grpc_out=stovepipe/gateway/protopb --go-grpc_opt=paths=source_relative \
352- --yarpc-go_out=stovepipe/gateway/protopb --yarpc-go_opt=paths=source_relative \
353- --proto_path=stovepipe/gateway/proto stovepipe/gateway/proto/gateway.proto
354- @protoc --go_out=stovepipe/orchestrator/protopb --go_opt=paths=source_relative \
355- --go-grpc_out=stovepipe/orchestrator/protopb --go-grpc_opt=paths=source_relative \
356- --yarpc-go_out=stovepipe/orchestrator/protopb --yarpc-go_opt=paths=source_relative \
357- --proto_path=stovepipe/orchestrator/proto stovepipe/orchestrator/proto/orchestrator.proto
343+ @echo " Generating protobuf files with Bazel..."
344+ @$(BAZEL ) build //tool/proto:generated
345+ @set -e; for pkg in $( PROTO_PACKAGES) ; do \
346+ out=$$(echo $$pkg | tr / _ ) ; base=$$(basename $$pkg) ; \
347+ for f in $$ base.pb.go $$ base.pb.yarpc.go $$ {base}_grpc.pb.go; do \
348+ cp -f bazel-bin/tool/proto/$$ out/$$ f $$ pkg/protopb/$$ f; \
349+ done ; \
350+ done
351+ @$(BAZEL ) run @rules_go//go -- run golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION ) -w $(addsuffix /protopb,$(PROTO_PACKAGES ) )
358352 @echo " Protobuf files generated successfully!"
359353
360354# Bazel query helpers
0 commit comments