-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (78 loc) · 3.73 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Define the output directories for Golang and JavaScript protobuf files
PROTO_GO_OUT := $(PWD)/dist/go
PROTO_JS_OUT := $(PWD)/dist/js
PROTO_PROTOSETS_OUT := $(PWD)/dist/protosets
PROTO_PROTOSETS_OUT_FILENAME := unpack.protoset
PROTO_DOCS_OUT := $(PWD)/dist/docs
# Define the path to the protoc binary
PROTOC := protoc
# Define the plugins and their paths for Golang and JavaScript
PROTOC_PLUGIN_GO := --go-grpc_out=paths=source_relative:$(PROTO_GO_OUT) --go_out=paths=source_relative:$(PROTO_GO_OUT)
PROTOC_PLUGIN_JS := --js_out=import_style=commonjs,binary:$(PROTO_JS_OUT) --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:$(PROTO_JS_OUT)
# Define the colors for the output messages
GREEN := "\033[32m"
RESET := "\033[0m"
PROTO_FILES := $(wildcard $(PWD)/common/*.proto \
$(PWD)/health/*.proto \
$(PWD)/sources/*.proto \
$(PWD)/metadata/*.proto \
$(PWD)/unpack/*.proto \
$(PWD)/ast/*.proto \
$(PWD)/ir/*.proto \
$(PWD)/abi/*.proto \
$(PWD)/eip/*.proto \
$(PWD)/opcode/*.proto \
$(PWD)/audit/*.proto \
$(PWD)/contracts/*.proto \
$(PWD)/server/*.proto \
)
# Define the commands to generate protobuf files for Golang and JavaScript
build: build-go build-js
@echo $(GREEN) "All protobuf files generated successfully!" $(RESET)
build-go:
@if [ ! -d "$(PROTO_GO_OUT)" ]; then mkdir -p "$(PROTO_GO_OUT)"; fi
@if [ ! -d "$(PROTO_PROTOSETS_OUT)" ]; then mkdir -p "$(PROTO_PROTOSETS_OUT)"; fi
@if [ ! -d "$(PROTO_DOCS_OUT)" ]; then mkdir -p "$(PROTO_DOCS_OUT)"; fi
@$(PROTOC) $(PROTOC_PLUGIN_GO) \
-Ithird_party/googleapis \
-Ithird_party/xds \
--descriptor_set_out=$(PROTO_PROTOSETS_OUT)/$(PROTO_PROTOSETS_OUT_FILENAME) \
--include_source_info \
--include_imports \
--proto_path=$(PWD) $(PROTO_FILES)
@echo $(GREEN) "Golang protobuf files generated successfully!" $(RESET)
build-js:
@if [ ! -d "$(PROTO_JS_OUT)" ]; then mkdir -p "$(PROTO_JS_OUT)"; fi
@if [ ! -d "$(PROTO_PROTOSETS_OUT)" ]; then mkdir -p "$(PROTO_PROTOSETS_OUT)"; fi
@if [ ! -d "$(PROTO_DOCS_OUT)" ]; then mkdir -p "$(PROTO_DOCS_OUT)"; fi
@$(PROTOC) $(PROTOC_PLUGIN_JS) \
-Ithird_party/googleapis \
-Ithird_party/xds \
-Inode_modules/.bin \
--proto_path=$(PWD) $(PROTO_FILES)
@echo $(GREEN) "JavaScript protobuf files generated successfully!" $(RESET)
clean:
# @rm -rf $(PROTO_GO_OUT)/*
@rm -rf $(PROTO_JS_OUT)/*
@rm -rf $(PROTO_DOCS_OUT)/*
@rm -rf $(PROTO_PROTOSETS_OUT)/*
@echo $(GREEN) "All protobuf files removed successfully!" $(RESET)
submodule:
git submodule update --init --recursive
deps: submodule
@which protoc >/dev/null || (echo "protoc not found. Please install protobuf compiler" && exit 1)
@which protoc-gen-go >/dev/null || (echo "protoc-gen-go not found. Installing..." && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest)
@which protoc-gen-go-grpc >/dev/null || (echo "protoc-gen-go-grpc not found. Installing..." && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest)
@which protoc-gen-docs >/dev/null || (echo "protoc-gen-docs not found. Installing..." && go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc)
@which protoc-gen-js >/dev/null || (echo "protoc-gen-js not found. Installing..." && npm install grpc-tools)
@which protoc-gen-grpc-web >/dev/null || (echo "protoc-gen-grpc-web not found. Installing..." && npm install protoc-gen-grpc-web)
@echo $(GREEN) "All dependencies installed successfully!" $(RESET)
help:
@echo "Available targets:"
@echo " build : Build Golang and JavaScript protobuf files"
@echo " build-go : Build Golang protobuf files"
@echo " build-js : Build JavaScript protobuf files"
@echo " clean : Remove all generated protobuf files"
@echo " deps : Install missing dependencies"
.DEFAULT_GOAL := help
.PHONY: build build-go build-js clean deps help