generate_protos.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 -ex
  6. # cd to repository root
  7. cd $(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 where the namespace matches the target location
  39. $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
  40. --csharp_opt=base_namespace=Google.Protobuf \
  41. src/google/protobuf/map_unittest_proto3.proto \
  42. src/google/protobuf/unittest_proto3.proto \
  43. src/google/protobuf/unittest_import_proto3.proto \
  44. src/google/protobuf/unittest_import_public_proto3.proto \
  45. src/google/protobuf/unittest_well_known_types.proto
  46. # Different base namespace to the protos above
  47. $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
  48. --csharp_opt=base_namespace=UnitTest.Issues \
  49. csharp/protos/unittest_issues.proto
  50. # AddressBook sample protos
  51. $PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
  52. examples/addressbook.proto
  53. $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
  54. conformance/conformance.proto