generate_protos.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. $PROTOC -Isrc -Icsharp/protos \
  40. --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
  41. --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
  42. --include_source_info \
  43. --include_imports \
  44. csharp/protos/map_unittest_proto3.proto \
  45. csharp/protos/unittest_issues.proto \
  46. csharp/protos/unittest_custom_options_proto3.proto \
  47. csharp/protos/unittest_proto3.proto \
  48. csharp/protos/unittest_import_proto3.proto \
  49. csharp/protos/unittest_import_public_proto3.proto \
  50. src/google/protobuf/unittest_well_known_types.proto \
  51. src/google/protobuf/test_messages_proto3.proto
  52. # AddressBook sample protos
  53. $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
  54. examples/addressbook.proto
  55. $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
  56. conformance/conformance.proto