OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Run this script to regenerate descriptor.pb.{h,cc} after the protocol | 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 | 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" | 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 | 6 # will fail if these files do not match what the protocol compiler would |
7 # generate. | 7 # generate. |
8 # | 8 # |
9 # HINT: Flags passed to generate_descriptor_proto.sh will be passed directly | 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 | 10 # to make when building protoc. This is particularly useful for passing |
(...skipping 25 matching lines...) Expand all Loading... |
36 google/protobuf/empty.proto \ | 36 google/protobuf/empty.proto \ |
37 google/protobuf/field_mask.proto \ | 37 google/protobuf/field_mask.proto \ |
38 google/protobuf/source_context.proto \ | 38 google/protobuf/source_context.proto \ |
39 google/protobuf/struct.proto \ | 39 google/protobuf/struct.proto \ |
40 google/protobuf/timestamp.proto \ | 40 google/protobuf/timestamp.proto \ |
41 google/protobuf/type.proto \ | 41 google/protobuf/type.proto \ |
42 google/protobuf/wrappers.proto) | 42 google/protobuf/wrappers.proto) |
43 | 43 |
44 CORE_PROTO_IS_CORRECT=0 | 44 CORE_PROTO_IS_CORRECT=0 |
45 PROCESS_ROUND=1 | 45 PROCESS_ROUND=1 |
| 46 TMP=$(mktemp -d) |
46 echo "Updating descriptor protos..." | 47 echo "Updating descriptor protos..." |
47 while [ $CORE_PROTO_IS_CORRECT -ne 1 ] | 48 while [ $CORE_PROTO_IS_CORRECT -ne 1 ] |
48 do | 49 do |
49 echo "Round $PROCESS_ROUND" | 50 echo "Round $PROCESS_ROUND" |
50 CORE_PROTO_IS_CORRECT=1 | 51 CORE_PROTO_IS_CORRECT=1 |
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 | |
56 cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.t
mp | |
57 cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc
.tmp | |
58 | 52 |
59 make $@ protoc && | 53 make $@ protoc |
60 ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. ${RUNTIME_PROTO_FILES
[@]} && \ | 54 if test $? -ne 0; then |
61 ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compile
r/plugin.proto | 55 echo "Failed to build protoc." |
| 56 exit 1 |
| 57 fi |
| 58 |
| 59 ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:$TMP ${RUNTIME_PROTO_FILE
S[@]} && \ |
| 60 ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:$TMP google/protobuf/compil
er/plugin.proto |
62 | 61 |
63 for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do | 62 for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do |
64 BASE_NAME=${PROTO_FILE%.*} | 63 BASE_NAME=${PROTO_FILE%.*} |
65 diff ${BASE_NAME}.pb.h ${BASE_NAME}.pb.h.tmp > /dev/null | 64 diff ${BASE_NAME}.pb.h $TMP/${BASE_NAME}.pb.h > /dev/null |
66 if test $? -ne 0; then | 65 if test $? -ne 0; then |
67 CORE_PROTO_IS_CORRECT=0 | 66 CORE_PROTO_IS_CORRECT=0 |
68 fi | 67 fi |
69 diff ${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc.tmp > /dev/null | 68 diff ${BASE_NAME}.pb.cc $TMP/${BASE_NAME}.pb.cc > /dev/null |
70 if test $? -ne 0; then | 69 if test $? -ne 0; then |
71 CORE_PROTO_IS_CORRECT=0 | 70 CORE_PROTO_IS_CORRECT=0 |
72 fi | 71 fi |
73 done | 72 done |
74 | 73 |
75 diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h
.tmp > /dev/null | 74 diff google/protobuf/compiler/plugin.pb.h $TMP/google/protobuf/compiler/plugin
.pb.h > /dev/null |
76 if test $? -ne 0; then | 75 if test $? -ne 0; then |
77 CORE_PROTO_IS_CORRECT=0 | 76 CORE_PROTO_IS_CORRECT=0 |
78 fi | 77 fi |
79 diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.
cc.tmp > /dev/null | 78 diff google/protobuf/compiler/plugin.pb.cc $TMP/google/protobuf/compiler/plugi
n.pb.cc > /dev/null |
80 if test $? -ne 0; then | 79 if test $? -ne 0; then |
81 CORE_PROTO_IS_CORRECT=0 | 80 CORE_PROTO_IS_CORRECT=0 |
82 fi | 81 fi |
83 | 82 |
84 for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do | 83 # Only override the output if the files are different to avoid re-compilation |
85 BASE_NAME=${PROTO_FILE%.*} | 84 # of the protoc. |
86 rm ${BASE_NAME}.pb.h.tmp | 85 if [ $CORE_PROTO_IS_CORRECT -ne 1 ]; then |
87 rm ${BASE_NAME}.pb.cc.tmp | 86 for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do |
88 done | 87 BASE_NAME=${PROTO_FILE%.*} |
89 rm google/protobuf/compiler/plugin.pb.h.tmp | 88 mv $TMP/${BASE_NAME}.pb.h ${BASE_NAME}.pb.h |
90 rm google/protobuf/compiler/plugin.pb.cc.tmp | 89 mv $TMP/${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc |
| 90 done |
| 91 mv $TMP/google/protobuf/compiler/plugin.pb.* google/protobuf/compiler/ |
| 92 fi |
91 | 93 |
92 PROCESS_ROUND=$((PROCESS_ROUND + 1)) | 94 PROCESS_ROUND=$((PROCESS_ROUND + 1)) |
93 done | 95 done |
94 cd .. | 96 cd .. |
95 | 97 |
96 if test -x objectivec/generate_descriptors_proto.sh; then | 98 if test -x objectivec/generate_well_known_types.sh; then |
97 echo "Generating messages for objc." | 99 echo "Generating messages for objc." |
98 objectivec/generate_descriptors_proto.sh $@ | 100 objectivec/generate_well_known_types.sh $@ |
99 fi | 101 fi |
| 102 |
| 103 if test -x csharp/generate_protos.sh; then |
| 104 echo "Generating messages for C#." |
| 105 csharp/generate_protos.sh $@ |
| 106 fi |
OLD | NEW |