temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Run this script to regenerate descriptor.pb.{h,cc} after the protocol |
| 4 | # compiler changes. Since these files are compiled into the protocol compiler |
| 5 | # itself, they cannot be generated automatically by a make rule. "make check" |
| 6 | # will fail if these files do not match what the protocol compiler would |
| 7 | # generate. |
kenton@google.com | 80b1d62 | 2009-07-29 01:13:20 +0000 | [diff] [blame] | 8 | # |
| 9 | # HINT: Flags passed to generate_descriptor_proto.sh will be passed directly |
| 10 | # to make when building protoc. This is particularly useful for passing |
| 11 | # -j4 to run 4 jobs simultaneously. |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 12 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 13 | if test ! -e src/google/protobuf/stubs/common.h; then |
| 14 | cat >&2 << __EOF__ |
| 15 | Could not find source code. Make sure you are running this script from the |
| 16 | root of the distribution tree. |
| 17 | __EOF__ |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | if test ! -e src/Makefile; then |
| 22 | cat >&2 << __EOF__ |
| 23 | Could not find src/Makefile. You must run ./configure (and perhaps |
| 24 | ./autogen.sh) first. |
| 25 | __EOF__ |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
kenton@google.com | 2f669cb | 2008-12-02 05:59:15 +0000 | [diff] [blame] | 29 | cd src |
Feng Xiao | 33c9280 | 2015-05-11 13:47:41 -0700 | [diff] [blame] | 30 | |
| 31 | declare -a RUNTIME_PROTO_FILES=(\ |
| 32 | google/protobuf/any.proto \ |
| 33 | google/protobuf/api.proto \ |
| 34 | google/protobuf/descriptor.proto \ |
| 35 | google/protobuf/duration.proto \ |
| 36 | google/protobuf/empty.proto \ |
| 37 | google/protobuf/field_mask.proto \ |
| 38 | google/protobuf/source_context.proto \ |
| 39 | google/protobuf/struct.proto \ |
| 40 | google/protobuf/timestamp.proto \ |
| 41 | google/protobuf/type.proto \ |
| 42 | google/protobuf/wrappers.proto) |
| 43 | |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 44 | CORE_PROTO_IS_CORRECT=0 |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 45 | PROCESS_ROUND=1 |
| 46 | echo "Updating descriptor protos..." |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 47 | while [ $CORE_PROTO_IS_CORRECT -ne 1 ] |
| 48 | do |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 49 | echo "Round $PROCESS_ROUND" |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 50 | CORE_PROTO_IS_CORRECT=1 |
Feng Xiao | 33c9280 | 2015-05-11 13:47:41 -0700 | [diff] [blame] | 51 | for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do |
| 52 | BASE_NAME=${PROTO_FILE%.*} |
| 53 | cp ${BASE_NAME}.pb.h ${BASE_NAME}.pb.h.tmp |
| 54 | cp ${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc.tmp |
| 55 | done |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 56 | cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp |
| 57 | cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp |
| 58 | |
Jisi Liu | 0b3cfc7 | 2015-03-02 10:54:10 -0800 | [diff] [blame] | 59 | make $@ protoc && |
Feng Xiao | 33c9280 | 2015-05-11 13:47:41 -0700 | [diff] [blame] | 60 | ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. ${RUNTIME_PROTO_FILES[@]} && \ |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 61 | ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto |
| 62 | |
Feng Xiao | 33c9280 | 2015-05-11 13:47:41 -0700 | [diff] [blame] | 63 | for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do |
| 64 | BASE_NAME=${PROTO_FILE%.*} |
| 65 | diff ${BASE_NAME}.pb.h ${BASE_NAME}.pb.h.tmp > /dev/null |
| 66 | if test $? -ne 0; then |
| 67 | CORE_PROTO_IS_CORRECT=0 |
| 68 | fi |
| 69 | diff ${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc.tmp > /dev/null |
| 70 | if test $? -ne 0; then |
| 71 | CORE_PROTO_IS_CORRECT=0 |
| 72 | fi |
| 73 | done |
| 74 | |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 75 | diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null |
| 76 | if test $? -ne 0; then |
| 77 | CORE_PROTO_IS_CORRECT=0 |
| 78 | fi |
| 79 | diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null |
| 80 | if test $? -ne 0; then |
| 81 | CORE_PROTO_IS_CORRECT=0 |
| 82 | fi |
| 83 | |
Feng Xiao | 33c9280 | 2015-05-11 13:47:41 -0700 | [diff] [blame] | 84 | for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do |
| 85 | BASE_NAME=${PROTO_FILE%.*} |
| 86 | rm ${BASE_NAME}.pb.h.tmp |
| 87 | rm ${BASE_NAME}.pb.cc.tmp |
| 88 | done |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 89 | rm google/protobuf/compiler/plugin.pb.h.tmp |
| 90 | rm google/protobuf/compiler/plugin.pb.cc.tmp |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 91 | |
| 92 | PROCESS_ROUND=$((PROCESS_ROUND + 1)) |
Jisi Liu | 885b612 | 2015-02-28 14:51:22 -0800 | [diff] [blame] | 93 | done |
kenton@google.com | 2f669cb | 2008-12-02 05:59:15 +0000 | [diff] [blame] | 94 | cd .. |