Skip to content

Commit

Permalink
check protoc version to make sure >= 3.5 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Feb 22, 2021
1 parent cde7c2c commit 46e15fb
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions scripts/install-protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,33 @@ function install_protoc () {
exit 1
fi

protoc --version
}

function check_protoc_version () {
# libprotoc 3.11.3
protocVersion=$(protoc --version | cut -d' ' -f 2)
majorVer=$(echo $protocVersion | cut -d. -f 1)
minorVer=$(echo $protocVersion | cut -d. -f 2)

(($majorVer == 3)) || {
echo "protoc major version must >= 3 (the installed version is $protocVersion)"
exit 1
}

# https://github.com/wechaty/grpc/issues/116
(($minorVer >= 5)) || {
echo "protoc minor version must >= 5 (the installed version is $protocVersion)"
exit 1
}

echo "protoc version check: v${protocVersion} OK"
}

function install_protoc_gen_lint () {
go get -u github.com/ckaznocha/protoc-gen-lint
}

function install_google_api () {
function install_proto_google_api () {
if [ -d ${THIRD_PARTY_DIR}/google/api ]; then
echo "install skipped: ${THIRD_PARTY_DIR}/google/api exists"
return
Expand All @@ -39,9 +58,22 @@ function install_google_api () {
mkdir -p ${THIRD_PARTY_DIR}/google/api
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > ${THIRD_PARTY_DIR}/google/api/annotations.proto
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > ${THIRD_PARTY_DIR}/google/api/http.proto
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > ${THIRD_PARTY_DIR}/google/api/http.proto
}

function install_protoc_gen_openapiv2 () {
# function install_google_protobuf_wrappers () {
# if [ -d ${THIRD_PARTY_DIR}/google/protobuf ]; then
# echo "install skipped: ${THIRD_PARTY_DIR}/google/protobuf exists"
# return
# fi

# wget \
# --directory-prefix ${THIRD_PARTY_DIR}/google/protobuf \
# https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf/wrappers.proto \
# https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf/descriptor.proto
# }

function install_proto_protoc_gen_openapiv2 () {
if [ -d ${THIRD_PARTY_DIR}/protoc-gen-openapiv2/options ]; then
echo "install skipped: ${THIRD_PARTY_DIR}/protoc-gen-openapiv2/options exists"
return
Expand All @@ -54,9 +86,12 @@ function install_protoc_gen_openapiv2 () {

function main () {
install_protoc
install_google_api
check_protoc_version

install_protoc_gen_lint
install_protoc_gen_openapiv2

install_proto_google_api
install_proto_protoc_gen_openapiv2
}

main

0 comments on commit 46e15fb

Please sign in to comment.