From 54613cc45b2e47a7cd76ea117308c418637cccf1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 20 Aug 2020 17:53:58 +0200 Subject: [PATCH] upb codegen: put .upbdefs.h and .upbdefs.c files in a different directory --- tools/codegen/core/gen_upb_api.sh | 18 +++++++++++++++++- tools/distrib/check_upb_output.sh | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/codegen/core/gen_upb_api.sh b/tools/codegen/core/gen_upb_api.sh index 2d89c6fa02c..7c546de6f05 100755 --- a/tools/codegen/core/gen_upb_api.sh +++ b/tools/codegen/core/gen_upb_api.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 diff --git a/tools/distrib/check_upb_output.sh b/tools/distrib/check_upb_output.sh index 6febd0e9835..f3697c0937e 100755 --- a/tools/distrib/check_upb_output.sh +++ b/tools/distrib/check_upb_output.sh @@ -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"