generate_protos.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # Generates C# source files from .proto files.
  3. # You first need to make sure protoc has been built (see instructions on
  4. # building protoc in root of this repository)
  5. set -e
  6. # cd to repository root
  7. pushd $(dirname $0)/..
  8. # Protocol buffer compiler to use. If the PROTOC variable is set,
  9. # use that. Otherwise, probe for expected locations under both
  10. # Windows and Unix.
  11. if [ -z "$PROTOC" ]; then
  12. # TODO(jonskeet): Use an array and a for loop instead?
  13. if [ -x cmake/build/Debug/protoc.exe ]; then
  14. PROTOC=cmake/build/Debug/protoc.exe
  15. elif [ -x cmake/build/Release/protoc.exe ]; then
  16. PROTOC=cmake/build/Release/protoc.exe
  17. elif [ -x src/protoc ]; then
  18. PROTOC=src/protoc
  19. else
  20. echo "Unable to find protocol buffer compiler."
  21. exit 1
  22. fi
  23. fi
  24. # descriptor.proto and well-known types
  25. $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
  26. --csharp_opt=base_namespace=Google.Protobuf \
  27. src/google/protobuf/descriptor.proto \
  28. src/google/protobuf/any.proto \
  29. src/google/protobuf/api.proto \
  30. src/google/protobuf/duration.proto \
  31. src/google/protobuf/empty.proto \
  32. src/google/protobuf/field_mask.proto \
  33. src/google/protobuf/source_context.proto \
  34. src/google/protobuf/struct.proto \
  35. src/google/protobuf/timestamp.proto \
  36. src/google/protobuf/type.proto \
  37. src/google/protobuf/wrappers.proto
  38. # Test protos
  39. # Note that this deliberately does *not* include old_extensions1.proto
  40. # and old_extensions2.proto, which are generated with an older version
  41. # of protoc.
  42. $PROTOC -Isrc -Icsharp/protos \
  43. --experimental_allow_proto3_optional \
  44. --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
  45. --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
  46. --include_source_info \
  47. --include_imports \
  48. csharp/protos/map_unittest_proto3.proto \
  49. csharp/protos/unittest_issues.proto \
  50. csharp/protos/unittest_custom_options_proto3.proto \
  51. csharp/protos/unittest_proto3.proto \
  52. csharp/protos/unittest_import_proto3.proto \
  53. csharp/protos/unittest_import_public_proto3.proto \
  54. csharp/protos/unittest.proto \
  55. csharp/protos/unittest_import.proto \
  56. csharp/protos/unittest_import_public.proto \
  57. csharp/protos/unittest_issue6936_a.proto \
  58. csharp/protos/unittest_issue6936_b.proto \
  59. csharp/protos/unittest_issue6936_c.proto \
  60. csharp/protos/unittest_selfreferential_options.proto \
  61. src/google/protobuf/unittest_well_known_types.proto \
  62. src/google/protobuf/test_messages_proto3.proto \
  63. src/google/protobuf/test_messages_proto2.proto \
  64. src/google/protobuf/unittest_proto3_optional.proto
  65. # AddressBook sample protos
  66. $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
  67. examples/addressbook.proto
  68. $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
  69. conformance/conformance.proto
  70. # Benchmark protos
  71. $PROTOC -Ibenchmarks \
  72. benchmarks/datasets/google_message1/proto3/*.proto \
  73. benchmarks/benchmarks.proto \
  74. --csharp_out=csharp/src/Google.Protobuf.Benchmarks
  75. # C# only benchmark protos
  76. $PROTOC -Isrc -Icsharp/src/Google.Protobuf.Benchmarks \
  77. csharp/src/Google.Protobuf.Benchmarks/*.proto \
  78. --csharp_out=csharp/src/Google.Protobuf.Benchmarks