proto tools install script (#7294)

Follow up of #7266 (comment)

Replace the convoluted Makefile in contrib/devtools/
with a separate (almost) idempotent install script.
This commit is contained in:
Alessio Treglia
2020-09-14 14:30:12 +01:00
committed by GitHub
parent 5e16c215ba
commit 56e3bc1945
2 changed files with 161 additions and 67 deletions
+10 -67
View File
@@ -51,7 +51,15 @@ STATIK = $(TOOLS_DESTDIR)/statik
RUNSIM = $(TOOLS_DESTDIR)/runsim
tools: tools-stamp
tools-stamp: proto-tools statik runsim
tools-stamp: statik runsim
# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row.
touch $@
proto-tools: proto-tools-stamp
proto-tools-stamp:
bash $(mkfile_dir)/proto-tools-installer.sh
# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row.
@@ -77,73 +85,8 @@ $(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0)
PROTOC_VERSION ?= 3.13.0
PROTOC_GRPC_GATEWAY_VERSION = 1.14.7
ifeq ($(UNAME_S),Linux)
PROTOC_ZIP ?= protoc-3.13.0-linux-x86_64.zip
PROTOC_GRPC_GATEWAY_BIN ?= protoc-gen-grpc-gateway-v1.14.7-linux-x86_64
endif
ifeq ($(UNAME_S),Darwin)
PROTOC_ZIP ?= protoc-3.13.0-osx-x86_64.zip
PROTOC_GRPC_GATEWAY_BIN ?= protoc-gen-grpc-gateway-v1.14.7-darwin-x86_64
endif
proto-tools: buf
ifeq (, $(shell which protoc))
@echo "Installing protoc compiler..."
@(cd /tmp; \
curl -OL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"; \
unzip -o ${PROTOC_ZIP} -d $(PREFIX) bin/protoc; \
unzip -o ${PROTOC_ZIP} -d $(PREFIX) 'include/*'; \
rm -f ${PROTOC_ZIP})
else
@echo "protoc already installed; skipping..."
endif
ifeq (, $(shell which protoc-gen-gocosmos))
@echo "Installing protoc-gen-gocosmos..."
@go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos
else
@echo "protoc-gen-gocosmos already installed; skipping..."
endif
ifeq (, $(shell which protoc-gen-grpc-gateway))
@echo "Installing protoc-gen-grpc-gateway..."
@curl -o "${BIN}/protoc-gen-grpc-gateway" -L "https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v${PROTOC_GRPC_GATEWAY_VERSION}/${PROTOC_GRPC_GATEWAY_BIN}"
@chmod +x "${BIN}/protoc-gen-grpc-gateway"
else
@echo "protoc-gen-grpc-gateway already installed; skipping..."
endif
ifeq (, $(shell which protoc-gen-swagger))
@echo "Installing protoc-gen-swagger..."
@go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
@npm install -g swagger-combine
else
@echo "protoc-gen-grpc-gateway already installed; skipping..."
endif
ifeq ($(UNAME_S),Linux)
@echo "Installing clang-format..."
sudo apt-get install clang-format
endif
ifeq ($(UNAME_S),Darwin)
@echo "Installing clang-format..."
brew install clang-format
endif
buf: buf-stamp
buf-stamp:
@echo "Installing buf..."
@curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
touch $@
tools-clean:
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
rm -f tools-stamp proto-tools-stamp buf-stamp
rm -f proto-tools-stamp tools-stamp
.PHONY: tools-clean statik runsim