From d7d61e9a6ce631430d1472b2bf222549dff7705b Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 20 Nov 2019 15:09:54 +0400 Subject: [PATCH] tools.mk: install protoc - works only for Linux / Mac 64bit - you need to call it manually - make protoc - on Mac, brew install protoc might be favorable --- Makefile | 15 +-------------- tools.mk | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index bf92387b0..f440e945b 100644 --- a/Makefile +++ b/Makefile @@ -71,19 +71,6 @@ install_abci: dist: @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'" -#For ABCI and libs -get_protoc: - @# https://github.com/google/protobuf/releases - curl -L https://github.com/google/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz | tar xvz && \ - cd protobuf-3.6.1 && \ - DIST_LANG=cpp ./configure && \ - make && \ - make check && \ - sudo make install && \ - sudo ldconfig && \ - cd .. && \ - rm -rf protobuf-3.6.1 - go-mod-cache: go.sum @echo "--> Download go modules to local cache" @go mod download @@ -247,7 +234,7 @@ contract-tests: # unless there is a reason not to. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html .PHONY: check build build_race build_abci dist install install_abci check_tools tools update_tools draw_deps \ - get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver fmt build-linux localnet-start \ + protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver fmt build-linux localnet-start \ localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop protoc_grpc protoc_all \ build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests \ build_c-amazonlinux diff --git a/tools.mk b/tools.mk index fe1df8276..3ad1f52dc 100644 --- a/tools.mk +++ b/tools.mk @@ -35,7 +35,7 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) ### -# tools +# Go tools ### TOOLS_DESTDIR ?= $(GOPATH)/bin @@ -63,7 +63,7 @@ $(CERTSTRAP): protobuf: $(PROTOBUF) $(PROTOBUF): - @echo "Get Protobuf" + @echo "Get GoGo Protobuf" @go get github.com/gogo/protobuf/protoc-gen-gogo@v1.3.1 # used to build tm-monitor binaries @@ -80,5 +80,32 @@ $(GOODMAN): tools-clean: rm -f $(CERTSTRAP) $(PROTOBUF) $(GOX) $(GOODMAN) rm -f tools-stamp + rm -rf /usr/local/include/google/protobuf + rm -f /usr/local/bin/protoc -.PHONY: all tools tools-clean +### +# Non Go tools +### + +# Choose protobuf binary based on OS (only works for 64bit Linux and Mac). +# NOTE: On Mac, installation via brew (brew install protoc) might be favorable. +PROTOC_ZIP="" +ifneq ($(OS),Windows_NT) + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + PROTOC_ZIP="protoc-3.10.1-linux-x86_64.zip" + endif + ifeq ($(UNAME_S),Darwin) + PROTOC_ZIP="protoc-3.10.1-osx-x86_64.zip" + endif +endif + +protoc: + @echo "Get Protobuf" + @echo "In case of any errors, please install directly from https://github.com/protocolbuffers/protobuf/releases" + @curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.10.1/$(PROTOC_ZIP) + @unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc + @unzip -o $(PROTOC_ZIP) -d /usr/local 'include/*' + @rm -f $(PROTOC_ZIP) + +.PHONY: all tools tools-clean protoc