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 | |
Yihua Zhang | 04fb58e | 2018-03-08 06:49:24 -0800 | [diff] [blame] | 18 | readonly NANOPB_ALTS_TMP_OUTPUT="$(mktemp -d)" |
David Garcia Quintas | e86b457 | 2016-02-23 17:38:01 -0800 | [diff] [blame] | 19 | readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 20 | readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 21 | |
| 22 | # install protoc version 3 |
| 23 | pushd third_party/protobuf |
| 24 | ./autogen.sh |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 25 | ./configure --prefix="$PROTOBUF_INSTALL_PREFIX" |
Jan Tattermusch | 7dd2cc6 | 2016-12-20 17:15:39 +0100 | [diff] [blame] | 26 | make -j 8 |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 27 | make install |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 28 | #ldconfig |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 29 | popd |
| 30 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 31 | readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin" |
| 32 | if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then |
| 33 | echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'" |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 34 | exit 1 |
| 35 | fi |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 36 | |
Craig Tiller | eb841e2 | 2016-02-11 15:49:16 -0800 | [diff] [blame] | 37 | # stack up and change to nanopb's proto generator directory |
| 38 | pushd third_party/nanopb/generator/proto |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 39 | export PATH="$PROTOC_BIN_PATH:$PATH" |
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 | # back to the root directory |
| 42 | popd |
| 43 | |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 44 | # |
David Garcia Quintas | 8c8cd02 | 2018-06-22 10:57:01 -0700 | [diff] [blame] | 45 | # Checks for load_balancer.proto |
David Garcia Quintas | d6b4628 | 2016-04-01 19:06:44 -0700 | [diff] [blame] | 46 | # |
David Garcia Quintas | 8c8cd02 | 2018-06-22 10:57:01 -0700 | [diff] [blame] | 47 | readonly LOAD_BALANCER_GRPC_OUTPUT_PATH='src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1' |
| 48 | # nanopb-compile the proto to a temp location |
| 49 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 50 | src/proto/grpc/lb/v1/load_balancer.proto \ |
| 51 | "$NANOPB_TMP_OUTPUT" \ |
| 52 | "$LOAD_BALANCER_GRPC_OUTPUT_PATH" |
| 53 | |
| 54 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 55 | third_party/protobuf/src/google/protobuf/duration.proto \ |
| 56 | "$NANOPB_TMP_OUTPUT/google/protobuf" \ |
| 57 | "$LOAD_BALANCER_GRPC_OUTPUT_PATH/google/protobuf" |
| 58 | |
| 59 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 60 | third_party/protobuf/src/google/protobuf/timestamp.proto \ |
| 61 | "$NANOPB_TMP_OUTPUT/google/protobuf" \ |
| 62 | "$LOAD_BALANCER_GRPC_OUTPUT_PATH/google/protobuf" |
| 63 | |
| 64 | # compare outputs to checked compiled code |
| 65 | if ! diff -r "$NANOPB_TMP_OUTPUT" src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1; then |
| 66 | echo "Outputs differ: $NANOPB_TMP_OUTPUT vs $LOAD_BALANCER_GRPC_OUTPUT_PATH" |
| 67 | exit 2 |
| 68 | fi |
Yihua Zhang | 04fb58e | 2018-03-08 06:49:24 -0800 | [diff] [blame] | 69 | |
| 70 | # |
| 71 | # Checks for handshaker.proto and transport_security_common.proto |
| 72 | # |
| 73 | readonly HANDSHAKER_GRPC_OUTPUT_PATH='src/core/tsi/alts/handshaker' |
| 74 | # nanopb-compile the proto to a temp location |
| 75 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 76 | src/core/tsi/alts/handshaker/proto/handshaker.proto \ |
| 77 | "$NANOPB_ALTS_TMP_OUTPUT" \ |
| 78 | "$HANDSHAKER_GRPC_OUTPUT_PATH" |
| 79 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 80 | src/core/tsi/alts/handshaker/proto/transport_security_common.proto \ |
| 81 | "$NANOPB_ALTS_TMP_OUTPUT" \ |
| 82 | "$HANDSHAKER_GRPC_OUTPUT_PATH" |
| 83 | ./tools/codegen/core/gen_nano_proto.sh \ |
| 84 | src/core/tsi/alts/handshaker/proto/altscontext.proto \ |
| 85 | "$NANOPB_ALTS_TMP_OUTPUT" \ |
| 86 | "$HANDSHAKER_GRPC_OUTPUT_PATH" |
| 87 | |
| 88 | # compare outputs to checked compiled code |
| 89 | for NANOPB_OUTPUT_FILE in $NANOPB_ALTS_TMP_OUTPUT/*.pb.*; do |
| 90 | if ! diff "$NANOPB_OUTPUT_FILE" "src/core/tsi/alts/handshaker/$(basename $NANOPB_OUTPUT_FILE)"; then |
| 91 | echo "Outputs differ: $NANOPB_ALTS_TMP_OUTPUT vs $HANDSHAKER_GRPC_OUTPUT_PATH" |
| 92 | exit 2 |
| 93 | fi |
| 94 | done |