blob: 6b98619c320a4b889b25794ac1c1e46382777e70 [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
Yihua Zhang04fb58e2018-03-08 06:49:24 -080018readonly NANOPB_ALTS_TMP_OUTPUT="$(mktemp -d)"
David Garcia Quintase86b4572016-02-23 17:38:01 -080019readonly NANOPB_TMP_OUTPUT="$(mktemp -d)"
David Garcia Quintasd6b46282016-04-01 19:06:44 -070020readonly PROTOBUF_INSTALL_PREFIX="$(mktemp -d)"
Craig Tillereb841e22016-02-11 15:49:16 -080021
22# install protoc version 3
23pushd third_party/protobuf
24./autogen.sh
David Garcia Quintasd6b46282016-04-01 19:06:44 -070025./configure --prefix="$PROTOBUF_INSTALL_PREFIX"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010026make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080027make install
David Garcia Quintasd6b46282016-04-01 19:06:44 -070028#ldconfig
Craig Tillereb841e22016-02-11 15:49:16 -080029popd
30
David Garcia Quintasd6b46282016-04-01 19:06:44 -070031readonly PROTOC_BIN_PATH="$PROTOBUF_INSTALL_PREFIX/bin"
32if [ ! -x "$PROTOBUF_INSTALL_PREFIX/bin/protoc" ]; then
33 echo "Error: protoc not found in temp install dir '$PROTOBUF_INSTALL_PREFIX'"
Craig Tillereb841e22016-02-11 15:49:16 -080034 exit 1
35fi
David Garcia Quintasd6b46282016-04-01 19:06:44 -070036
Craig Tillereb841e22016-02-11 15:49:16 -080037# stack up and change to nanopb's proto generator directory
38pushd third_party/nanopb/generator/proto
David Garcia Quintasd6b46282016-04-01 19:06:44 -070039export PATH="$PROTOC_BIN_PATH:$PATH"
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010040make -j 8
Craig Tillereb841e22016-02-11 15:49:16 -080041# back to the root directory
42popd
43
David Garcia Quintasd6b46282016-04-01 19:06:44 -070044#
David Garcia Quintas8c8cd022018-06-22 10:57:01 -070045# Checks for load_balancer.proto
David Garcia Quintasd6b46282016-04-01 19:06:44 -070046#
David Garcia Quintas8c8cd022018-06-22 10:57:01 -070047readonly 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
65if ! 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
68fi
Yihua Zhang04fb58e2018-03-08 06:49:24 -080069
70#
71# Checks for handshaker.proto and transport_security_common.proto
72#
73readonly 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
89for 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
94done