2022-04-22 14:18:44 +00:00
|
|
|
GOBINREL = build/bin
|
|
|
|
GOBIN = $(CURDIR)/$(GOBINREL)
|
2021-07-01 15:35:06 +00:00
|
|
|
GOBUILD = env GO111MODULE=on go build -trimpath
|
|
|
|
OS = $(shell uname -s)
|
|
|
|
ARCH = $(shell uname -m)
|
|
|
|
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
PROTOC_OS := osx
|
|
|
|
endif
|
|
|
|
ifeq ($(OS),Linux)
|
|
|
|
PROTOC_OS = linux
|
|
|
|
endif
|
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
PROTOC_INCLUDE = build/include/google
|
|
|
|
|
|
|
|
default: gen
|
2021-09-17 02:56:04 +00:00
|
|
|
|
|
|
|
gen: grpc mocks
|
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
$(GOBINREL):
|
|
|
|
mkdir -p "$(GOBIN)"
|
2021-07-01 15:35:06 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
$(GOBINREL)/protoc: | $(GOBINREL)
|
2021-07-01 15:35:06 +00:00
|
|
|
$(eval PROTOC_TMP := $(shell mktemp -d))
|
2022-04-22 14:18:44 +00:00
|
|
|
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.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
|
2021-07-01 15:35:06 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
protoc-all: $(GOBINREL)/protoc $(PROTOC_INCLUDE) $(GOBINREL)/protoc-gen-go $(GOBINREL)/protoc-gen-go-grpc
|
2021-07-25 12:19:33 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
protoc-clean:
|
|
|
|
rm -f "$(GOBIN)/protoc"*
|
|
|
|
rm -rf "$(PROTOC_INCLUDE)"
|
|
|
|
|
|
|
|
grpc: protoc-all
|
|
|
|
PATH="$(GOBIN):$(PATH)" protoc --proto_path=interfaces --go_out=gointerfaces -I=$(PROTOC_INCLUDE) \
|
2021-07-01 15:35:06 +00:00
|
|
|
types/types.proto
|
2022-04-22 14:18:44 +00:00
|
|
|
PATH="$(GOBIN):$(PATH)" protoc --proto_path=interfaces --go_out=gointerfaces --go-grpc_out=gointerfaces -I=$(PROTOC_INCLUDE) \
|
2021-07-01 15:44:00 +00:00
|
|
|
--go_opt=Mtypes/types.proto=github.com/ledgerwatch/erigon-lib/gointerfaces/types \
|
|
|
|
--go-grpc_opt=Mtypes/types.proto=github.com/ledgerwatch/erigon-lib/gointerfaces/types \
|
2021-07-01 15:35:06 +00:00
|
|
|
p2psentry/sentry.proto \
|
|
|
|
remote/kv.proto remote/ethbackend.proto \
|
2021-12-14 13:33:32 +00:00
|
|
|
downloader/downloader.proto \
|
2021-07-01 15:35:06 +00:00
|
|
|
consensus_engine/consensus.proto \
|
2022-01-20 09:31:34 +00:00
|
|
|
starknet/cairo.proto \
|
2021-07-01 15:35:06 +00:00
|
|
|
testing/testing.proto \
|
|
|
|
txpool/txpool.proto txpool/mining.proto
|
2021-07-25 12:19:33 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
$(GOBINREL)/moq: | $(GOBINREL)
|
|
|
|
$(GOBUILD) -o "$(GOBIN)/moq" github.com/matryer/moq
|
|
|
|
|
|
|
|
mocks: $(GOBINREL)/moq
|
|
|
|
PATH="$(GOBIN):$(PATH)" go generate ./...
|
|
|
|
|
|
|
|
lint: $(GOBINREL)/golangci-lint
|
|
|
|
@"$(GOBIN)/golangci-lint" run --config ./.golangci.yml
|
2021-09-17 02:56:04 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
# force re-make golangci-lint
|
|
|
|
lintci-deps: lintci-deps-clean $(GOBINREL)/golangci-lint
|
|
|
|
lintci-deps-clean: golangci-lint-clean
|
2021-09-15 13:15:32 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
# download and build golangci-lint (https://golangci-lint.run)
|
|
|
|
$(GOBINREL)/golangci-lint: | $(GOBINREL)
|
2022-04-28 08:11:28 +00:00
|
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(GOBIN)" v1.45.2
|
2021-09-15 13:15:32 +00:00
|
|
|
|
2022-04-22 14:18:44 +00:00
|
|
|
golangci-lint-clean:
|
|
|
|
rm -f "$(GOBIN)/golangci-lint"
|