blob: a30b73f68925928a8cbe3f85ee6ae3e25629d52e [file] [log] [blame]
Craig Tillereb841e22016-02-11 15:49:16 -08001#!/bin/bash
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002# Copyright 2015 gRPC authors.
Craig Tillereb841e22016-02-11 15:49:16 -08003#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
Craig Tillereb841e22016-02-11 15:49:16 -08007#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008# http://www.apache.org/licenses/LICENSE-2.0
Craig Tillereb841e22016-02-11 15:49:16 -08009#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Craig Tillereb841e22016-02-11 15:49:16 -080015
16set -ex
17
David Garcia Quintase86b4572016-02-23 17:38:01 -080018readonly NANOPB_TMP_OUTPUT="$(mktemp -d)"
David Garcia Quintasd6b46282016-04-01 19:06:44 -070019readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)"
Craig Tillereb841e22016-02-11 15:49:16 -080020
21# install protoc version 3
22pushd third_party/protobuf
23./autogen.sh
David Garcia Quintasd6b46282016-04-01 19:06:44 -070024./configure --prefix="$PROTOBUF_INSTALL_PREFIX"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010025make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080026make install
David Garcia Quintasd6b46282016-04-01 19:06:44 -070027#ldconfig
Craig Tillereb841e22016-02-11 15:49:16 -080028popd
29
David Garcia Quintasd6b46282016-04-01 19:06:44 -070030readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin"
31if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then
32 echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'"
Craig Tillereb841e22016-02-11 15:49:16 -080033 exit 1
34fi
David Garcia Quintasd6b46282016-04-01 19:06:44 -070035
Craig Tillereb841e22016-02-11 15:49:16 -080036# stack up and change to nanopb's proto generator directory
37pushd third_party/nanopb/generator/proto
David Garcia Quintasd6b46282016-04-01 19:06:44 -070038export PATH="$PROTOC_BIN_PATH:$PATH"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010039make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080040# back to the root directory
41popd
42
David Garcia Quintasd6b46282016-04-01 19:06:44 -070043#
44# Checks for load_balancer.proto
45#
Craig Tiller9eb0fde2017-03-31 16:59:30 -070046readonly LOAD_BALANCER_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1'
Craig Tillereb841e22016-02-11 15:49:16 -080047# nanopb-compile the proto to a temp location
David Garcia Quintasd6b46282016-04-01 19:06:44 -070048./tools/codegen/core/gen_nano_proto.sh \
David Garcia Quintas7f0793a2016-04-25 12:35:58 -070049 src/proto/grpc/lb/v1/load_balancer.proto \
David Garcia Quintasd6b46282016-04-01 19:06:44 -070050 "$NANOPB_TMP_OUTPUT" \
51 "$LOAD_BALANCER_GRPC_OUTPUT_PATH"
Craig Tillereb841e22016-02-11 15:49:16 -080052
53# compare outputs to checked compiled code
Mehrdad Afshari7b0a3fb2018-01-11 18:27:34 -080054if ! diff -r "$NANOPB_TMP_OUTPUT" src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then
David Garcia Quintasd6b46282016-04-01 19:06:44 -070055 echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH"
David Garcia Quintase86b4572016-02-23 17:38:01 -080056 exit 2
Craig Tillereb841e22016-02-11 15:49:16 -080057fi