Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 2 | # Copyright 2015, Google Inc. |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 3 | # 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 | |
| 31 | set -ex |
| 32 | |
David Garcia Quintas | e86b457 | 2016-02-23 17:38:01 -0800 | [diff] [blame] | 33 | readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 34 | readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 35 | |
| 36 | # install protoc version 3 |
| 37 | pushd third_party/protobuf |
| 38 | ./autogen.sh |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 39 | ./configure --prefix="$PROTOBUF_INSTALL_PREFIX" |
Jan Tattermusch | 7dd2cc6 | 2016-12-20 17:15:39 +0100 | [diff] [blame] | 40 | make -j 8 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 41 | make install |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 42 | #ldconfig |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 43 | popd |
| 44 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 45 | readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin" |
| 46 | if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then |
| 47 | echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 48 | exit 1 |
| 49 | fi |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 50 | |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 51 | # stack up and change to nanopb's proto generator directory |
| 52 | pushd third_party/nanopb/generator/proto |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 53 | export PATH="$PROTOC_BIN_PATH:$PATH" |
Jan Tattermusch | 7dd2cc6 | 2016-12-20 17:15:39 +0100 | [diff] [blame] | 54 | make -j 8 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 55 | # back to the root directory |
| 56 | popd |
| 57 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 58 | # |
| 59 | # Checks for load_balancer.proto |
| 60 | # |
Craig Tiller | 9eb0fde | 2017-03-31 16:59:30 -0700 | [diff] [blame] | 61 | readonly LOAD_BALANCER_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1' |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 62 | # nanopb-compile the proto to a temp location |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 63 | ./tools/codegen/core/gen_nano_proto.sh \ |
David Garcia Quintas | 7f0793a | 2016-04-25 12:35:58 -0700 | [diff] [blame] | 64 | src/proto/grpc/lb/v1/load_balancer.proto \ |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 65 | "$NANOPB_TMP_OUTPUT" \ |
| 66 | "$LOAD_BALANCER_GRPC_OUTPUT_PATH" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 67 | |
| 68 | # compare outputs to checked compiled code |
Craig Tiller | 9eb0fde | 2017-03-31 16:59:30 -0700 | [diff] [blame] | 69 | if ! diff -r $NANOPB_TMP_OUTPUT src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 70 | echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH" |
David Garcia Quintas | e86b457 | 2016-02-23 17:38:01 -0800 | [diff] [blame] | 71 | exit 2 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 72 | fi |