generate_descriptor_proto.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. # Run this script to regenerate descriptor.pb.{h,cc} after the protocol
  3. # compiler changes. Since these files are compiled into the protocol compiler
  4. # itself, they cannot be generated automatically by a make rule. "make check"
  5. # will fail if these files do not match what the protocol compiler would
  6. # generate.
  7. #
  8. # HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
  9. # to make when building protoc. This is particularly useful for passing
  10. # -j4 to run 4 jobs simultaneously.
  11. if test ! -e src/google/protobuf/stubs/common.h; then
  12. cat >&2 << __EOF__
  13. Could not find source code. Make sure you are running this script from the
  14. root of the distribution tree.
  15. __EOF__
  16. exit 1
  17. fi
  18. if test ! -e src/Makefile; then
  19. cat >&2 << __EOF__
  20. Could not find src/Makefile. You must run ./configure (and perhaps
  21. ./autogen.sh) first.
  22. __EOF__
  23. exit 1
  24. fi
  25. cd src
  26. make $@ google/protobuf/stubs/pbconfig.h
  27. CORE_PROTO_IS_CORRECT=0
  28. while [ $CORE_PROTO_IS_CORRECT -ne 1 ]
  29. do
  30. CORE_PROTO_IS_CORRECT=1
  31. cp google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp
  32. cp google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp
  33. cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp
  34. cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp
  35. make $@ protoc &&
  36. ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. google/protobuf/descriptor.proto && \
  37. ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto
  38. diff google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp > /dev/null
  39. if test $? -ne 0; then
  40. CORE_PROTO_IS_CORRECT=0
  41. fi
  42. diff google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp > /dev/null
  43. if test $? -ne 0; then
  44. CORE_PROTO_IS_CORRECT=0
  45. fi
  46. diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null
  47. if test $? -ne 0; then
  48. CORE_PROTO_IS_CORRECT=0
  49. fi
  50. diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null
  51. if test $? -ne 0; then
  52. CORE_PROTO_IS_CORRECT=0
  53. fi
  54. rm google/protobuf/descriptor.pb.h.tmp
  55. rm google/protobuf/descriptor.pb.cc.tmp
  56. rm google/protobuf/compiler/plugin.pb.h.tmp
  57. rm google/protobuf/compiler/plugin.pb.cc.tmp
  58. done
  59. cd ..