OLD | NEW |
(Empty) | |
| 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 |
| 6 # This script performs a few fix-ups as part of generation. These are: |
| 7 # - descriptor.proto is renamed to descriptor_proto_file.proto before |
| 8 # generation, to avoid the naming collision between the class for the file |
| 9 # descriptor and its Descriptor property |
| 10 # - This change also impacts UnittestCustomOptions, which expects to |
| 11 # use a class of Descriptor when it's actually been renamed to |
| 12 # DescriptorProtoFile. |
| 13 # - Issue 307 (codegen for double-nested types) breaks Unittest.proto and |
| 14 # its lite equivalents. |
| 15 |
| 16 set -ex |
| 17 |
| 18 # cd to repository root |
| 19 cd $(dirname $0)/.. |
| 20 |
| 21 # Protocol buffer compiler to use. If the PROTOC variable is set, |
| 22 # use that. Otherwise, probe for expected locations under both |
| 23 # Windows and Unix. |
| 24 if [ -z "$PROTOC" ]; then |
| 25 # TODO(jonskeet): Use an array and a for loop instead? |
| 26 if [ -x cmake/build/Debug/protoc.exe ]; then |
| 27 PROTOC=cmake/build/Debug/protoc.exe |
| 28 elif [ -x cmake/build/Release/protoc.exe ]; then |
| 29 PROTOC=cmake/build/Release/protoc.exe |
| 30 elif [ -x src/protoc ]; then |
| 31 PROTOC=src/protoc |
| 32 else |
| 33 echo "Unable to find protocol buffer compiler." |
| 34 exit 1 |
| 35 fi |
| 36 fi |
| 37 |
| 38 # descriptor.proto and well-known types |
| 39 $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ |
| 40 --csharp_opt=base_namespace=Google.Protobuf \ |
| 41 src/google/protobuf/descriptor.proto \ |
| 42 src/google/protobuf/any.proto \ |
| 43 src/google/protobuf/api.proto \ |
| 44 src/google/protobuf/duration.proto \ |
| 45 src/google/protobuf/empty.proto \ |
| 46 src/google/protobuf/field_mask.proto \ |
| 47 src/google/protobuf/source_context.proto \ |
| 48 src/google/protobuf/struct.proto \ |
| 49 src/google/protobuf/timestamp.proto \ |
| 50 src/google/protobuf/type.proto \ |
| 51 src/google/protobuf/wrappers.proto |
| 52 |
| 53 # Test protos where the namespace matches the target location |
| 54 $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \ |
| 55 --csharp_opt=base_namespace=Google.Protobuf \ |
| 56 src/google/protobuf/map_unittest_proto3.proto \ |
| 57 src/google/protobuf/unittest_proto3.proto \ |
| 58 src/google/protobuf/unittest_import_proto3.proto \ |
| 59 src/google/protobuf/unittest_import_public_proto3.proto \ |
| 60 src/google/protobuf/unittest_well_known_types.proto |
| 61 |
| 62 # Different base namespace to the protos above |
| 63 $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \ |
| 64 --csharp_opt=base_namespace=UnitTest.Issues \ |
| 65 csharp/protos/unittest_issues.proto |
| 66 |
| 67 # AddressBook sample protos |
| 68 $PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ |
| 69 examples/addressbook.proto |
| 70 |
| 71 $PROTOC -Iconformance --csharp_out=csharp/src/Google.Protobuf.Conformance \ |
| 72 conformance/conformance.proto |
OLD | NEW |