-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
67 lines (58 loc) · 2.62 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
PROJECT_NAME := "dusk-protobuf"
PKG := "github.com/dusk-network/$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
#TEST_FLAGS := "-count=1"
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
RUSK_PKG := github.com/dusk-network/dusk-protobuf/autogen/go/rusk
.PHONY: all go clean gen regen-dir help
go: gen-monitor gen-rusk gen-node ## Generate the RPC golang structs
@echo "generated packages"
PROTOC := $(shell which protoc)
ifeq ($(shell uname), Linux)
protoc=protoc-3.19.1-linux-x86_64.zip
else
protoc = protoc-3.19.1-osx-x86_64.zip
endif
download-protoc:
@echo $(OS)
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/$(protoc)
mkdir -p ./tmp/protoc
unzip -o $(protoc) -d ./tmp/protoc bin/protoc
unzip -o $(protoc) -d ./tmp/protoc 'include/*'
rm -f $(protoc)
go install github.com/golang/protobuf/protoc-gen-go@latest
all: regen-dir mock go ## Recreates the autogen folder and calls regen
mock: mock-monitor mock-rusk mock-node ## Generate the mockups
@echo "generated mocks"
clean: ## Remove previously autogenerated files
@echo "removing $(PWD)/autogen folder"
@rm -rf ./autogen
regen-dir: clean
@echo "creating $(PWD)/autogen/go/{monitor,rusk,node} folders"
@mkdir -p ./autogen/go/{monitor,rusk,node}
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
mock-monitor:
@protoc -I./monitor --gogo_out=plugins=grpc,paths=source_relative:./autogen/go/monitor --gogrpcmock_out=paths=source_relative:./autogen/go/monitor ./monitor/*.proto
mock-node:
@protoc -I./node --gogo_out=plugins=grpc,paths=source_relative:./autogen/go/node --gogrpcmock_out=paths=source_relative:./autogen/go/node ./node/*.proto
gen-monitor:
@protoc -I./monitor/ ./monitor/*.proto --go_out=plugins=grpc,paths=source_relative:./autogen/go/monitor
gen-node:
@protoc -I./node/ ./node/*.proto --go_out=plugins=grpc,paths=source_relative:./autogen/go/node
gen-rusk: download-protoc
git clone [email protected]:dusk-network/rusk.git
./tmp/protoc/bin/protoc \
-I./rusk/rusk-schema/protos/ ./rusk/rusk-schema/protos/*.proto \
--go_out=plugins=grpc,paths=source_relative:./autogen/go/rusk \
--go_opt=Mstate.proto=$(RUSK_PKG) \
--go_opt=Mecho.proto=$(RUSK_PKG) \
--go_opt=Mnetwork.proto=$(RUSK_PKG) \
--go_opt=Mprover.proto=$(RUSK_PKG) \
--go_opt=Mprovisioner.proto=$(RUSK_PKG) \
--go_opt=Mkeys.proto=$(RUSK_PKG) \
--go_opt=Mtransaction.proto=$(RUSK_PKG) \
--go_opt=Mstake.proto=$(RUSK_PKG) \
--go_opt=Mreward.proto=$(RUSK_PKG) \
--go_opt=Mtransfer.proto=$(RUSK_PKG)
rm -rf ./rusk