@@ -8,6 +8,7 @@ GOPATH := $(shell go env GOPATH)
88endif
99
1010PROTO_ROOT := temporal-proto
11+ COLOR := "\e[1;36m%s\e[0m\n"
1112# List only subdirectories with *.proto files. Sort to remove duplicates.
1213PROTO_DIRS = $(sort $(dir $(wildcard $(PROTO_ROOT ) /* /* .proto) ) )
1314PROTO_SERVICES = $(wildcard $(PROTO_ROOT ) /* /service.proto)
@@ -16,7 +17,7 @@ PROTO_IMPORT := $(PROTO_ROOT):$(GOPATH)/src/github.com/gogo/protobuf/protobuf
1617
1718update-proto : update-proto-submodule all
1819
19- all : grpc grpc-mock copyright gomodtidy
20+ all : grpc grpc-mock copyright update-dependencies gomodtidy
2021
2122all-install : grpc-install mockgen-install
2223
@@ -26,26 +27,27 @@ $(PROTO_OUT):
2627# git submodule for proto files
2728
2829update-proto-submodule :
30+ printf $(COLOR ) " Update proto-submodule..."
2931 git submodule update --init --remote $(PROTO_ROOT )
3032
3133# Compile proto files to go
3234
3335grpc : gogo-grpc
3436
3537gogo-grpc : clean $(PROTO_OUT )
36- echo " Compiling for gogo-gRPC..."
38+ printf $( COLOR ) " Compiling for gogo-gRPC..."
3739 $(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,plugins=grpc,paths=source_relative:$(PROTO_OUT ) $(PROTO_DIR ) * .proto;)
3840
3941gogo-protobuf : clean $(PROTO_OUT )
40- echo " Compiling for gogo-protobuf..."
42+ printf $( COLOR ) " Compiling for gogo-protobuf..."
4143 $(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;)
4244
4345go-protobuf : clean $(PROTO_OUT )
44- echo " Compiling for go-protobuf..."
46+ printf $( COLOR ) " Compiling for go-protobuf..."
4547 $(foreach PROTO_DIR,$(PROTO_DIRS ) ,protoc --proto_path=$(PROTO_IMPORT ) --go_out=paths=source_relative:$(PROTO_OUT ) $(PROTO_DIR ) * .proto;)
4648
4749go-grpc : clean $(PROTO_OUT )
48- echo " Compiling for go-gRPC..."
50+ printf $( COLOR ) " Compiling for go-gRPC..."
4951 $(foreach PROTO_DIR,$(PROTO_DIRS ) ,protoc --proto_path=$(PROTO_IMPORT ) --go_out=plugins=grpc,paths=source_relative:$(PROTO_OUT ) $(PROTO_DIR ) * .proto;)
5052
5153# Generate mocks
@@ -56,36 +58,45 @@ dir_no_slash = $(patsubst %/,%,$(dir $(1)))
5658dirname = $(notdir $(call dir_no_slash,$(1 ) ) )
5759
5860grpc-mock :
59- @echo " Generate gRPC mocks..."
60- @ $(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 ) ) )
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 ) ) )
6163
6264# Plugins & tools
6365
6466grpc-install : gogo-protobuf-install
65- echo " Installing/updaing gRPC plugins ..."
66- GO111MODULE=off go get -u google.golang.org/grpc
67+ printf $( COLOR ) " Installing/updating gRPC plugin ..."
68+ go get -u google.golang.org/grpc
6769
6870gogo-protobuf-install : go-protobuf-install
69- GO111MODULE=off go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
71+ printf $(COLOR ) " Installing/updating gogo protobuf plugin..."
72+ go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
7073
7174go-protobuf-install :
72- GO111MODULE=off go get -u github.com/golang/protobuf/protoc-gen-go
75+ printf $(COLOR ) " Installing/updating go protobuf plugin..."
76+ go get -u github.com/golang/protobuf/protoc-gen-go
7377
7478mockgen-install :
75- GO111MODULE=off go get -u github.com/golang/mock/mockgen
79+ printf $(COLOR ) " Installing/updating mockgen..."
80+ go get -u github.com/golang/mock/mockgen
7681
7782# Add licence header to generated files
7883
7984copyright :
85+ printf $(COLOR ) " Update license headers..."
8086 go run ./cmd/copyright/licensegen.go
8187
8288# Keep go.mod updated
8389
90+ update-dependencies :
91+ printf $(COLOR ) " Update dependencies..."
92+ go get -u ./...
93+
8494gomodtidy :
95+ printf $(COLOR ) " Run 'go mod tidy'..."
8596 go mod tidy
8697
8798# clean
8899
89100clean :
90- echo " Deleting generated go files..."
101+ printf $( COLOR ) " Deleting generated go files..."
91102 rm -rf $(PROTO_OUT ) /* /* .pb.* go
0 commit comments