forked from temporalio/ui-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (54 loc) · 2.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
.ONESHELL:
.PHONY:
all: install-utils build
##### Variables ######
ifndef GOPATH
GOPATH := $(shell go env GOPATH)
endif
GOBIN := $(if $(shell go env GOBIN),$(shell go env GOBIN),$(GOPATH)/bin)
PATH := $(GOBIN):$(PATH)
COLOR := "\e[1;36m%s\e[0m\n"
PROTO_ROOT := proto/api
PROTO_FILES = $(shell find $(PROTO_ROOT) -name "*.proto")
PROTO_DIRS = $(sort $(dir $(PROTO_FILES)))
PROTO_OUT := api
PROTO_IMPORTS := \
-I $(PROTO_ROOT) \
-I ./proto/dependencies/github.com/grpc-ecosystem/grpc-gateway/ \
-I ./proto/dependencies/github.com/gogo/googleapis/ \
-I ./proto/dependencies/api/ \
-I ./proto/dependencies/
PROTO_REFS := Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api
OPENAPI_OUT := openapi/assets
##### Build #####
build: build-grpc build-server
build-server:
go mod tidy
go build -o ui-server ./cmd/server/main.go
build-grpc:
@printf $(COLOR) "Compiling gRPC..."
rm -rf $(PROTO_OUT)
mkdir -p $(PROTO_OUT)
$(foreach PROTO_DIR,$(PROTO_DIRS),\
protoc $(PROTO_IMPORTS) \
--gogoslick_out=plugins=grpc,paths=source_relative,$(PROTO_REFS):$(PROTO_OUT) \
--grpc-gateway_out=allow_patch_feature=false,paths=source_relative:$(PROTO_OUT) \
--openapiv2_out=$(OPENAPI_OUT) \
$(PROTO_DIR)*.proto \
;)
@printf $(COLOR) "Fixing gRPC output paths"
mv -f $(PROTO_OUT)/temporal/api/* $(PROTO_OUT) && rm -rf $(PROTO_OUT)/temporal
##### Install dependencies #####
install-utils:
@go install github.com/temporalio/gogo-protobuf/protoc-gen-gogoslick@latest
@GO111MODULE=off go get github.com/temporalio/gogo-protobuf/protoc-gen-gogoslick
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
@go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@latest
@go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
##### Test #####
test: clean-test-results
@printf $(COLOR) "Running unit tests..."
go test ./... -race
clean-test-results:
@rm -f test.log
@go clean -testcache