blob: 20fddf14f31434158f84c383617f6ab94ac0b0db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/bin/bash
#
# Example usage:
# tools/codegen/core/gen_load_balancing_proto.sh \
# src/core/client_config/lb_policies/proto/load_balancer.proto
if [ $# -eq 0 ]; then
echo "Usage: $0 <load_balancer.proto>"
exit 1
fi
readonly EXPECTED_OPTIONS_FILE_PATH="${1%.*}.options"
if [[ ! -f "$1" ]]; then
echo "Input proto file '$1' doesn't exist."
exit 2
fi
if [[ ! -f "${EXPECTED_OPTIONS_FILE_PATH}" ]]; then
echo "Expected nanopb options file '${EXPECTED_OPTIONS_FILE_PATH}' missing"
exit 3
fi
readonly GRPC_ROOT=$PWD
pushd "$(dirname $1)" > /dev/null
protoc \
--plugin=protoc-gen-nanopb="$GRPC_ROOT/third_party/nanopb/generator/protoc-gen-nanopb" \
--nanopb_out='-L#include\ \"third_party/nanopb/pb.h\"'":$GRPC_ROOT/src/core/proto" \
"$(basename $1)"
popd > /dev/null
|