generate_protos.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
  44. --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
  45. --include_source_info \
  46. --include_imports \
  47. csharp/protos/map_unittest_proto3.proto \
  48. csharp/protos/unittest_issues.proto \
  49. csharp/protos/unittest_custom_options_proto3.proto \
  50. csharp/protos/unittest_proto3.proto \
  51. csharp/protos/unittest_import_proto3.proto \
  52. csharp/protos/unittest_import_public_proto3.proto \
  53. csharp/protos/unittest.proto \
  54. csharp/protos/unittest_import.proto \
  55. csharp/protos/unittest_import_public.proto \
  56. csharp/protos/unittest_issue6936_a.proto \
  57. csharp/protos/unittest_issue6936_b.proto \
  58. csharp/protos/unittest_issue6936_c.proto \
  59. src/google/protobuf/unittest_well_known_types.proto \
  60. src/google/protobuf/test_messages_proto3.proto \
  61. src/google/protobuf/test_messages_proto2.proto \
  62. src/google/protobuf/unittest_proto3_optional.proto
  63. # AddressBook sample protos
  64. $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
  65. examples/addressbook.proto
  66. $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
  67. conformance/conformance.proto
  68. # Benchmark protos
  69. $PROTOC -Ibenchmarks \
  70. benchmarks/datasets/google_message1/proto3/*.proto \
  71. benchmarks/benchmarks.proto \
  72. --csharp_out=csharp/src/Google.Protobuf.Benchmarks
  73. # C# only benchmark protos
  74. $PROTOC -Isrc -Icsharp/src/Google.Protobuf.Benchmarks \
  75. csharp/src/Google.Protobuf.Benchmarks/*.proto \
  76. --csharp_out=csharp/src/Google.Protobuf.Benchmarks