From 5221dcbe479ed765d8103ed7601c69b6d8d6ca4f Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Fri, 29 Jan 2016 13:51:05 -0800 Subject: Integrate from google internal. Java files are moved to un-do the hack in the prevous commit, which moved the java files to the original position for integration. --- generate_descriptor_proto.sh | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'generate_descriptor_proto.sh') diff --git a/generate_descriptor_proto.sh b/generate_descriptor_proto.sh index cd906896..44006b2c 100755 --- a/generate_descriptor_proto.sh +++ b/generate_descriptor_proto.sh @@ -10,6 +10,8 @@ # to make when building protoc. This is particularly useful for passing # -j4 to run 4 jobs simultaneously. +set -e + if test ! -e src/google/protobuf/stubs/common.h; then cat >&2 << __EOF__ Could not find source code. Make sure you are running this script from the @@ -43,51 +45,48 @@ declare -a RUNTIME_PROTO_FILES=(\ CORE_PROTO_IS_CORRECT=0 PROCESS_ROUND=1 +TMP=$(mktemp -d) echo "Updating descriptor protos..." while [ $CORE_PROTO_IS_CORRECT -ne 1 ] do echo "Round $PROCESS_ROUND" CORE_PROTO_IS_CORRECT=1 - for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do - BASE_NAME=${PROTO_FILE%.*} - cp ${BASE_NAME}.pb.h ${BASE_NAME}.pb.h.tmp - cp ${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc.tmp - done - cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp - cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp make $@ protoc && - ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. ${RUNTIME_PROTO_FILES[@]} && \ - ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto + ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:$TMP ${RUNTIME_PROTO_FILES[@]} && \ + ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:$TMP google/protobuf/compiler/plugin.proto for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do BASE_NAME=${PROTO_FILE%.*} - diff ${BASE_NAME}.pb.h ${BASE_NAME}.pb.h.tmp > /dev/null + diff ${BASE_NAME}.pb.h $TMP/${BASE_NAME}.pb.h > /dev/null if test $? -ne 0; then CORE_PROTO_IS_CORRECT=0 fi - diff ${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc.tmp > /dev/null + diff ${BASE_NAME}.pb.cc $TMP/${BASE_NAME}.pb.cc > /dev/null if test $? -ne 0; then CORE_PROTO_IS_CORRECT=0 fi done - diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null + diff google/protobuf/compiler/plugin.pb.h $TMP/google/protobuf/compiler/plugin.pb.h > /dev/null if test $? -ne 0; then CORE_PROTO_IS_CORRECT=0 fi - diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null + diff google/protobuf/compiler/plugin.pb.cc $TMP/google/protobuf/compiler/plugin.pb.cc > /dev/null if test $? -ne 0; then CORE_PROTO_IS_CORRECT=0 fi - for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do - BASE_NAME=${PROTO_FILE%.*} - rm ${BASE_NAME}.pb.h.tmp - rm ${BASE_NAME}.pb.cc.tmp - done - rm google/protobuf/compiler/plugin.pb.h.tmp - rm google/protobuf/compiler/plugin.pb.cc.tmp + # Only override the output if the files are different to avoid re-compilation + # of the protoc. + if [ $CORE_PROTO_IS_CORRECT -ne 1 ]; then + for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do + BASE_NAME=${PROTO_FILE%.*} + mv $TMP/${BASE_NAME}.pb.h ${BASE_NAME}.pb.h + mv $TMP/${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc + done + mv $TMP/google/protobuf/compiler/plugin.pb.* google/protobuf/compiler/ + fi PROCESS_ROUND=$((PROCESS_ROUND + 1)) done -- cgit v1.2.3