Skip to content

Commit 9e11e84

Browse files
authored
Move all proto files to temporal package (#45)
1 parent 8c77016 commit 9e11e84

File tree

26 files changed

+2071
-2032
lines changed

26 files changed

+2071
-2032
lines changed

Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ ifndef GOPATH
77
GOPATH := $(shell go env GOPATH)
88
endif
99

10-
PROTO_ROOT := temporal-proto
1110
COLOR := "\e[1;36m%s\e[0m\n"
12-
# List only subdirectories with *.proto files. Sort to remove duplicates.
13-
PROTO_DIRS = $(sort $(dir $(wildcard $(PROTO_ROOT)/*/*/*.proto)))
14-
PROTO_SERVICES = $(wildcard $(PROTO_ROOT)/*/*/service.proto)
11+
12+
PROTO_ROOT := temporal-proto
13+
PROTO_DIRS = $(shell find $(PROTO_ROOT) -name "*.proto" -printf "%h\n" | sort -u)
1514
PROTO_OUT := .
1615
PROTO_IMPORT := $(PROTO_ROOT):$(GOPATH)/src/github.com/temporalio/gogo-protobuf/protobuf
1716

@@ -32,15 +31,15 @@ update-proto-submodule:
3231

3332
# Compile proto files to go
3433

35-
grpc: gogo-grpc
34+
grpc: gogo-grpc fix-path
3635

3736
gogo-grpc: clean $(PROTO_OUT)
3837
printf $(COLOR) "Compiling for gogo-gRPC..."
39-
$(foreach PROTO_DIR,$(PROTO_DIRS),protoc --proto_path=$(PROTO_IMPORT) --gogoslick_out=Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,plugins=grpc,paths=source_relative:$(PROTO_OUT) $(PROTO_DIR)*.proto;)
38+
$(foreach PROTO_DIR,$(PROTO_DIRS),protoc --proto_path=$(PROTO_IMPORT) --gogoslick_out=Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,plugins=grpc,paths=source_relative:$(PROTO_OUT) $(PROTO_DIR)/*.proto;)
4039

4140
gogo-protobuf: clean $(PROTO_OUT)
4241
printf $(COLOR) "Compiling for gogo-protobuf..."
43-
$(foreach PROTO_DIR,$(PROTO_DIRS),protoc --proto_path=$(PROTO_IMPORT) --gogofaster_out=Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,paths=source_relative:$(PROTO_OUT) $(PROTO_DIR)*.proto;)
42+
$(foreach PROTO_DIR,$(PROTO_DIRS),protoc --proto_path=$(PROTO_IMPORT) --gogofaster_out=Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,paths=source_relative:$(PROTO_OUT) $(PROTO_DIR)/*.proto;)
4443

4544
go-protobuf: clean $(PROTO_OUT)
4645
printf $(COLOR) "Compiling for go-protobuf..."
@@ -50,16 +49,19 @@ go-grpc: clean $(PROTO_OUT)
5049
printf $(COLOR) "Compiling for go-gRPC..."
5150
$(foreach PROTO_DIR,$(PROTO_DIRS),protoc --proto_path=$(PROTO_IMPORT) --go_out=plugins=grpc,paths=source_relative:$(PROTO_OUT) $(PROTO_DIR)*.proto;)
5251

52+
fix-path:
53+
mv -f $(PROTO_OUT)/temporal/* $(PROTO_OUT) && rm -d $(PROTO_OUT)/temporal
54+
5355
# Generate mocks
5456

55-
# All generated service files pathes relative to PROTO_OUT
57+
# All generated service files pathes relative to PROTO_OUT.
5658
PROTO_GRPC_SERVICES = $(patsubst $(PROTO_OUT)/%,%,$(shell find $(PROTO_OUT) -name "service.pb.go"))
5759
service_name = $(firstword $(subst /, ,$(1)))
5860
mock_file_name = $(call service_name,$(1))mock/$(subst $(call service_name,$(1))/,,$(1:go=mock.go))
5961

6062
grpc-mock:
6163
printf $(COLOR) "Generate gRPC mocks..."
62-
$(foreach PROTO_GRPC_SERVICE,$(PROTO_GRPC_SERVICES),cd $(PROTO_OUT) && mockgen -package $(call service_name,$(PROTO_GRPC_SERVICE))mock -source $(PROTO_GRPC_SERVICE) -destination $(call mock_file_name,$(PROTO_GRPC_SERVICE)) )
64+
$(foreach PROTO_GRPC_SERVICE,$(PROTO_GRPC_SERVICES),cd $(PROTO_OUT) && mockgen -package $(call service_name,$(PROTO_GRPC_SERVICE))mock -source $(PROTO_GRPC_SERVICE) -destination $(call mock_file_name,$(PROTO_GRPC_SERVICE))$(NEWLINE) )
6365

6466
# Plugins & tools
6567

@@ -95,8 +97,9 @@ gomodtidy:
9597
printf $(COLOR) "Run 'go mod tidy'..."
9698
go mod tidy
9799

98-
# clean
100+
# Clean
99101

100102
clean:
101103
printf $(COLOR) "Deleting generated go files..."
102-
rm -rf $(PROTO_OUT)/*/*/*.pb.*go
104+
# Delete all directories with *.pb.go and *.mock.go files from $(PROTO_OUT)
105+
$(foreach PROTO_OUT_DIR,$(shell find $(PROTO_OUT) \( -name "*.pb.go" -o -name "*.mock.go" \) -printf "%h\n" | sort -u),rm -rf $(dir $(PROTO_OUT_DIR)) )

common/v1/message.pb.go

Lines changed: 76 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)