Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | # Copyright 2015 gRPC authors. |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 3 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | # 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 Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 7 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 9 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | # 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 Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 15 | |
| 16 | set -ex |
| 17 | |
David Garcia Quintas | e86b457 | 2016-02-23 17:38:01 -0800 | [diff] [blame] | 18 | readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 19 | readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 20 | |
| 21 | # install protoc version 3 |
| 22 | pushd third_party/protobuf |
| 23 | ./autogen.sh |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 24 | ./configure --prefix="$PROTOBUF_INSTALL_PREFIX" |
Jan Tattermusch | 7dd2cc6 | 2016-12-20 17:15:39 +0100 | [diff] [blame] | 25 | make -j 8 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 26 | make install |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 27 | #ldconfig |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 28 | popd |
| 29 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 30 | readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin" |
| 31 | if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then |
| 32 | echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 33 | exit 1 |
| 34 | fi |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 35 | |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 36 | # stack up and change to nanopb's proto generator directory |
| 37 | pushd third_party/nanopb/generator/proto |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 38 | export PATH="$PROTOC_BIN_PATH:$PATH" |
Jan Tattermusch | 7dd2cc6 | 2016-12-20 17:15:39 +0100 | [diff] [blame] | 39 | make -j 8 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 40 | # back to the root directory |
| 41 | popd |
| 42 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 43 | # |
| 44 | # Checks for load_balancer.proto |
| 45 | # |
Craig Tiller | 9eb0fde | 2017-03-31 16:59:30 -0700 | [diff] [blame] | 46 | 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] | 47 | # nanopb-compile the proto to a temp location |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 48 | ./tools/codegen/core/gen_nano_proto.sh \ |
David Garcia Quintas | 7f0793a | 2016-04-25 12:35:58 -0700 | [diff] [blame] | 49 | src/proto/grpc/lb/v1/load_balancer.proto \ |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 50 | "$NANOPB_TMP_OUTPUT" \ |
| 51 | "$LOAD_BALANCER_GRPC_OUTPUT_PATH" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 52 | |
| 53 | # compare outputs to checked compiled code |
Mehrdad Afshari | 7b0a3fb | 2018-01-11 18:27:34 -0800 | [diff] [blame] | 54 | 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] | 55 | 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] | 56 | exit 2 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 57 | fi |