-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathMakefile
116 lines (94 loc) · 3.99 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
GOBINREL = build/bin
GOBIN = $(CURDIR)/$(GOBINREL)
BUILD_TAGS = nosqlite,noboltdb,disable_libutp
CGO_CXXFLAGS ?= $(shell go env CGO_CXXFLAGS 2>/dev/null)
ifeq ($(CGO_CXXFLAGS),)
CGO_CXXFLAGS += -g
CGO_CXXFLAGS += -O2
endif
GOBUILD = CGO_CXXFLAGS="$(CGO_CXXFLAGS)" go build -trimpath -tags $(BUILD_TAGS)
GOTEST = CGO_CXXFLAGS="$(CGO_CXXFLAGS)" go test -trimpath -tags $(BUILD_TAGS)
GOTEST_NOFUZZ = CGO_CXXFLAGS="$(CGO_CXXFLAGS)" go test -trimpath --tags=$(BUILD_TAGS),nofuzz
OS = $(shell uname -s)
ARCH = $(shell uname -m)
ifeq ($(OS),Darwin)
PROTOC_OS := osx
ifeq ($(ARCH),arm64)
ARCH = aarch_64
endif
endif
ifeq ($(OS),Linux)
PROTOC_OS = linux
endif
PROTOC_INCLUDE = build/include/google
PROTO_PATH = vendor/github.com/erigontech/interfaces
default: gen
gen: grpc mocks
$(GOBINREL):
mkdir -p "$(GOBIN)"
$(GOBINREL)/protoc: | $(GOBINREL)
$(eval PROTOC_TMP := $(shell mktemp -d))
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-$(PROTOC_OS)-$(ARCH).zip -o "$(PROTOC_TMP)/protoc.zip"
cd "$(PROTOC_TMP)" && unzip protoc.zip
cp "$(PROTOC_TMP)/bin/protoc" "$(GOBIN)"
mkdir -p "$(PROTOC_INCLUDE)"
cp -R "$(PROTOC_TMP)/include/google/" "$(PROTOC_INCLUDE)"
rm -rf "$(PROTOC_TMP)"
# 'protoc-gen-go' tool generates proto messages
$(GOBINREL)/protoc-gen-go: | $(GOBINREL)
$(GOBUILD) -o "$(GOBIN)/protoc-gen-go" google.golang.org/protobuf/cmd/protoc-gen-go
# 'protoc-gen-go-grpc' tool generates grpc services
$(GOBINREL)/protoc-gen-go-grpc: | $(GOBINREL)
$(GOBUILD) -o "$(GOBIN)/protoc-gen-go-grpc" google.golang.org/grpc/cmd/protoc-gen-go-grpc
protoc-all: $(GOBINREL)/protoc $(PROTOC_INCLUDE) $(GOBINREL)/protoc-gen-go $(GOBINREL)/protoc-gen-go-grpc
protoc-clean:
rm -f "$(GOBIN)/protoc"*
rm -rf "$(PROTOC_INCLUDE)"
grpc: protoc-all
go mod vendor
PATH="$(GOBIN):$(PATH)" protoc --proto_path=$(PROTO_PATH) --go_out=gointerfaces -I=$(PROTOC_INCLUDE) \
--go_opt=Mtypes/types.proto=./typesproto \
types/types.proto
PATH="$(GOBIN):$(PATH)" protoc --proto_path=$(PROTO_PATH) --go_out=gointerfaces --go-grpc_out=gointerfaces -I=$(PROTOC_INCLUDE) \
--go_opt=Mtypes/types.proto=github.com/erigontech/erigon-lib/gointerfaces/typesproto \
--go-grpc_opt=Mtypes/types.proto=github.com/erigontech/erigon-lib/gointerfaces/typesproto \
--go_opt=Mp2psentry/sentry.proto=./sentryproto \
--go-grpc_opt=Mp2psentry/sentry.proto=./sentryproto \
--go_opt=Mp2psentinel/sentinel.proto=./sentinelproto \
--go-grpc_opt=Mp2psentinel/sentinel.proto=./sentinelproto \
--go_opt=Mremote/kv.proto=./remoteproto \
--go-grpc_opt=Mremote/kv.proto=./remoteproto \
--go_opt=Mremote/ethbackend.proto=./remoteproto \
--go-grpc_opt=Mremote/ethbackend.proto=./remoteproto \
--go_opt=Mremote/bor.proto=./remoteproto \
--go-grpc_opt=Mremote/bor.proto=./remoteproto \
--go_opt=Mdownloader/downloader.proto=./downloaderproto \
--go-grpc_opt=Mdownloader/downloader.proto=./downloaderproto \
--go_opt=Mexecution/execution.proto=./executionproto \
--go-grpc_opt=Mexecution/execution.proto=./executionproto \
--go_opt=Mtxpool/txpool.proto=./txpoolproto \
--go-grpc_opt=Mtxpool/txpool.proto=./txpoolproto \
--go_opt=Mtxpool/mining.proto=./txpoolproto \
--go-grpc_opt=Mtxpool/mining.proto=./txpoolproto \
p2psentry/sentry.proto p2psentinel/sentinel.proto \
remote/bor.proto remote/kv.proto remote/ethbackend.proto \
downloader/downloader.proto execution/execution.proto \
txpool/txpool.proto txpool/mining.proto
rm -rf vendor
mocks:
rm -f $(GOBIN)/mockgen
$(GOBUILD) -o "$(GOBIN)/mockgen" go.uber.org/mock/mockgen
grep -r -l --exclude-dir="*$(GOBINREL)*" "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r
PATH="$(GOBIN):$(PATH)" go generate -run "mockgen" ./...
lintci-deps:
@./tools/golangci_lint.sh --install-deps
lintci:
@CGO_CXXFLAGS="$(CGO_CXXFLAGS)" ./tools/golangci_lint.sh
lint-mod-tidy:
@./tools/mod_tidy_check.sh
lint-deps: lintci-deps
lint: lintci lint-mod-tidy
test:
$(GOTEST) --count 1 -p 2 -coverprofile=coverage.out ./...
test-no-fuzz:
$(GOTEST_NOFUZZ) --count 1 -p 2 ./...