upb codegen: put .upbdefs.h and .upbdefs.c files in a different directory

pull/23904/head
Jan Tattermusch 4 years ago
parent 613333d805
commit 54613cc45b
  1. 18
      tools/codegen/core/gen_upb_api.sh
  2. 4
      tools/distrib/check_upb_output.sh

@ -21,10 +21,14 @@ bazel=`pwd`/tools/bazel
if [ $# -eq 0 ]; then
UPB_OUTPUT_DIR=$PWD/src/core/ext/upb-generated
UPBDEFS_OUTPUT_DIR=$PWD/src/core/ext/upbdefs-generated
rm -rf $UPB_OUTPUT_DIR
rm -rf $UPBDEFS_OUTPUT_DIR
mkdir -p $UPB_OUTPUT_DIR
else
UPB_OUTPUT_DIR=$1
UPB_OUTPUT_DIR=$1/upb-generated
UPBDEFS_OUTPUT_DIR=$1/upbdefs-generated
mkdir $UPB_OUTPUT_DIR
fi
$bazel build @com_google_protobuf//:protoc
@ -129,5 +133,17 @@ do
--plugin=protoc-gen-upb=$UPB_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

@ -16,8 +16,10 @@
set -ex
readonly UPB_GENERATED_SRC=src/core/ext/upb-generated
readonly UPBDEFS_GENERATED_SRC=src/core/ext/upbdefs-generated
readonly UPB_TMP_OUTPUT="$(mktemp -d)"
tools/codegen/core/gen_upb_api.sh "$UPB_TMP_OUTPUT"
diff -rq "$UPB_GENERATED_SRC" "$UPB_TMP_OUTPUT"
diff -rq "$UPB_GENERATED_SRC" "$UPB_TMP_OUTPUT/upb-generated"
diff -rq "$UPBDEFS_GENERATED_SRC" "$UPB_TMP_OUTPUT/upbdefs-generated"

Loading…
Cancel
Save