|
10 | 10 | PROTO_ROOT := temporal-proto |
11 | 11 | COLOR := "\e[1;36m%s\e[0m\n" |
12 | 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) |
| 13 | +PROTO_DIRS = $(sort $(dir $(wildcard $(PROTO_ROOT)/*/*/*.proto))) |
| 14 | +PROTO_SERVICES = $(wildcard $(PROTO_ROOT)/*/*/service.proto) |
15 | 15 | PROTO_OUT := . |
16 | 16 | PROTO_IMPORT := $(PROTO_ROOT):$(GOPATH)/src/github.com/temporalio/gogo-protobuf/protobuf |
17 | 17 |
|
@@ -54,12 +54,12 @@ go-grpc: clean $(PROTO_OUT) |
54 | 54 |
|
55 | 55 | # All generated service files pathes relative to PROTO_OUT |
56 | 56 | PROTO_GRPC_SERVICES = $(patsubst $(PROTO_OUT)/%,%,$(shell find $(PROTO_OUT) -name "service.pb.go")) |
57 | | -dir_no_slash = $(patsubst %/,%,$(dir $(1))) |
58 | | -dirname = $(notdir $(call dir_no_slash,$(1))) |
| 57 | +service_name = $(firstword $(subst /, ,$(1))) |
| 58 | +mock_file_name = $(call service_name,$(1))mock/$(subst $(call service_name,$(1))/,,$(1:go=mock.go)) |
59 | 59 |
|
60 | 60 | grpc-mock: |
61 | 61 | printf $(COLOR) "Generate gRPC mocks..." |
62 | | - $(foreach PROTO_GRPC_SERVICE,$(PROTO_GRPC_SERVICES),cd $(PROTO_OUT) && mockgen -package $(call dirname,$(PROTO_GRPC_SERVICE))mock -source $(PROTO_GRPC_SERVICE) -destination $(call dir_no_slash,$(PROTO_GRPC_SERVICE))mock/$(notdir $(PROTO_GRPC_SERVICE:go=mock.go)) ) |
| 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)) ) |
63 | 63 |
|
64 | 64 | # Plugins & tools |
65 | 65 |
|
@@ -99,4 +99,4 @@ gomodtidy: |
99 | 99 |
|
100 | 100 | clean: |
101 | 101 | printf $(COLOR) "Deleting generated go files..." |
102 | | - rm -rf $(PROTO_OUT)/*/*.pb.*go |
| 102 | + rm -rf $(PROTO_OUT)/*/*/*.pb.*go |
0 commit comments