Updated gen_upb_api.sh

pull/25037/head
Esun Kim 4 years ago
parent 603e6201e5
commit e4014fc2a6
  1. 46
      tools/codegen/core/gen_upb_api.sh

@ -25,17 +25,22 @@ if [ $# -eq 0 ]; then
rm -rf $UPB_OUTPUT_DIR
rm -rf $UPBDEFS_OUTPUT_DIR
mkdir -p $UPB_OUTPUT_DIR
mkdir -p $UPBDEFS_OUTPUT_DIR
else
UPB_OUTPUT_DIR=$1/upb-generated
UPBDEFS_OUTPUT_DIR=$1/upbdefs-generated
mkdir $UPB_OUTPUT_DIR
mkdir $UPBDEFS_OUTPUT_DIR
fi
$bazel build @com_google_protobuf//:protoc
PROTOC=$PWD/bazel-bin/external/com_google_protobuf/protoc
$bazel build @upb//:protoc-gen-upb
UPB_PLUGIN=$PWD/bazel-bin/external/upb/protoc-gen-upb
$bazel build @upb//upbc:protoc-gen-upb
UPB_PLUGIN=$PWD/bazel-bin/external/upb/upbc/protoc-gen-upb
$bazel build @upb//upbc:protoc-gen-upbdefs
UPBDEFS_PLUGIN=$PWD/bazel-bin/external/upb/upbc/protoc-gen-upbdefs
proto_files=( \
"envoy/annotations/deprecation.proto" \
@ -127,32 +132,27 @@ proto_files=( \
"udpa/core/v1/resource.proto" \
"validate/validate.proto")
INCLUDE_OPTIONS="-I=$PWD/third_party/udpa \
-I=$PWD/third_party/envoy-api \
-I=$PWD/third_party/googleapis \
-I=$PWD/third_party/protobuf/src \
-I=$PWD/third_party/protoc-gen-validate \
-I=$PWD"
for i in "${proto_files[@]}"
do
echo "Compiling: ${i}"
$PROTOC \
-I=$PWD/third_party/udpa \
-I=$PWD/third_party/envoy-api \
-I=$PWD/third_party/googleapis \
-I=$PWD/third_party/protobuf/src \
-I=$PWD/third_party/protoc-gen-validate \
-I=$PWD \
$INCLUDE_OPTIONS \
$i \
--upb_out=$UPB_OUTPUT_DIR \
--plugin=protoc-gen-upb=$UPB_PLUGIN
# In PHP build Makefile, the files with .upb.c suffix collide .upbdefs.c suffix due to a PHP buildsystem bug.
# Work around this by placing the generated files with ".upbdefs.h" and ".upbdefs.c" suffix under a different directory.
# See https://github.com/grpc/grpc/issues/23307
$PROTOC \
$INCLUDE_OPTIONS \
$i \
--upb_out=$UPBDEFS_OUTPUT_DIR \
--plugin=protoc-gen-upb=$UPBDEFS_PLUGIN
done
# In PHP build Makefile, the files with .upb.c suffix collide .upbdefs.c suffix due to a PHP buildsystem bug.
# Work around this by placing the generated files with ".upbdefs.h" and ".upbdefs.c" suffix under a different directory.
# See https://github.com/grpc/grpc/issues/23307
# move all .upbdefs.h and .upbdefs.c files from under src/core/ext/upb-generated to src/core/ext/upbdefs-generated
cp -r $UPB_OUTPUT_DIR $UPBDEFS_OUTPUT_DIR
# remove files that don't belong under upb-generated
find $UPB_OUTPUT_DIR -name "*.upbdefs.c" -type f -delete
find $UPB_OUTPUT_DIR -name "*.upbdefs.h" -type f -delete
# remove files that don't belong under upbdefs-generated
find $UPBDEFS_OUTPUT_DIR -name "*.upb.h" -type f -delete
find $UPBDEFS_OUTPUT_DIR -name "*.upb.c" -type f -delete

Loading…
Cancel
Save