blob: ba5028220743bf802898f36abc9a966b0a4610be [file] [log] [blame]
Craig Tillereb841e22016-02-11 15:49:16 -08001#!/bin/bash
Craig Tiller6169d5f2016-03-31 07:46:18 -07002# Copyright 2015, Google Inc.
Craig Tillereb841e22016-02-11 15:49:16 -08003# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above
12# copyright notice, this list of conditions and the following disclaimer
13# in the documentation and/or other materials provided with the
14# distribution.
15# * Neither the name of Google Inc. nor the names of its
16# contributors may be used to endorse or promote products derived from
17# this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31set -ex
32
David Garcia Quintase86b4572016-02-23 17:38:01 -080033readonly NANOPB_TMP_OUTPUT="$(mktemp -d)"
David Garcia Quintasd6b46282016-04-01 19:06:44 -070034readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)"
Craig Tillereb841e22016-02-11 15:49:16 -080035
36# install protoc version 3
37pushd third_party/protobuf
38./autogen.sh
David Garcia Quintasd6b46282016-04-01 19:06:44 -070039./configure --prefix="$PROTOBUF_INSTALL_PREFIX"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010040make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080041make install
David Garcia Quintasd6b46282016-04-01 19:06:44 -070042#ldconfig
Craig Tillereb841e22016-02-11 15:49:16 -080043popd
44
David Garcia Quintasd6b46282016-04-01 19:06:44 -070045readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin"
46if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then
47 echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'"
Craig Tillereb841e22016-02-11 15:49:16 -080048 exit 1
49fi
David Garcia Quintasd6b46282016-04-01 19:06:44 -070050
Craig Tillereb841e22016-02-11 15:49:16 -080051# stack up and change to nanopb's proto generator directory
52pushd third_party/nanopb/generator/proto
David Garcia Quintasd6b46282016-04-01 19:06:44 -070053export PATH="$PROTOC_BIN_PATH:$PATH"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010054make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080055# back to the root directory
56popd
57
David Garcia Quintasd6b46282016-04-01 19:06:44 -070058#
59# Checks for load_balancer.proto
60#
Craig Tiller9eb0fde2017-03-31 16:59:30 -070061readonly 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 -080062# nanopb-compile the proto to a temp location
David Garcia Quintasd6b46282016-04-01 19:06:44 -070063./tools/codegen/core/gen_nano_proto.sh \
David Garcia Quintas7f0793a2016-04-25 12:35:58 -070064 src/proto/grpc/lb/v1/load_balancer.proto \
David Garcia Quintasd6b46282016-04-01 19:06:44 -070065 "$NANOPB_TMP_OUTPUT" \
66 "$LOAD_BALANCER_GRPC_OUTPUT_PATH"
Craig Tillereb841e22016-02-11 15:49:16 -080067
68# compare outputs to checked compiled code
Craig Tiller9eb0fde2017-03-31 16:59:30 -070069if ! 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 -070070 echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH"
David Garcia Quintase86b4572016-02-23 17:38:01 -080071 exit 2
Craig Tillereb841e22016-02-11 15:49:16 -080072fi