generate_descriptor_proto.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. CORE_PROTO_IS_CORRECT=0
  27. while [ $CORE_PROTO_IS_CORRECT -ne 1 ]
  28. do
  29. CORE_PROTO_IS_CORRECT=1
  30. cp google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp
  31. cp google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp
  32. cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp
  33. cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp
  34. make $@ protoc &&
  35. ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. google/protobuf/descriptor.proto && \
  36. ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto
  37. diff google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp > /dev/null
  38. if test $? -ne 0; then
  39. CORE_PROTO_IS_CORRECT=0
  40. fi
  41. diff google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp > /dev/null
  42. if test $? -ne 0; then
  43. CORE_PROTO_IS_CORRECT=0
  44. fi
  45. diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null
  46. if test $? -ne 0; then
  47. CORE_PROTO_IS_CORRECT=0
  48. fi
  49. diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null
  50. if test $? -ne 0; then
  51. CORE_PROTO_IS_CORRECT=0
  52. fi
  53. rm google/protobuf/descriptor.pb.h.tmp
  54. rm google/protobuf/descriptor.pb.cc.tmp
  55. rm google/protobuf/compiler/plugin.pb.h.tmp
  56. rm google/protobuf/compiler/plugin.pb.cc.tmp
  57. done
  58. cd ..