Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 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 | |
Jon Skeet | b1a395c | 2015-05-15 14:36:07 +0100 | [diff] [blame] | 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 | |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 16 | set -ex |
| 17 | |
| 18 | # cd to repository root |
| 19 | cd $(dirname $0)/.. |
| 20 | |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 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? |
Jon Skeet | 09f3f4e | 2015-06-17 15:16:14 +0100 | [diff] [blame] | 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 |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 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 |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 37 | |
| 38 | # Descriptor proto |
Jon Skeet | b1a395c | 2015-05-15 14:36:07 +0100 | [diff] [blame] | 39 | # TODO(jonskeet): Remove fixup |
Jon Skeet | 59eeebe | 2015-07-17 08:26:04 +0100 | [diff] [blame] | 40 | $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/Reflection \ |
Jon Skeet | ca89a1a | 2015-08-25 14:32:28 +0100 | [diff] [blame^] | 41 | src/google/protobuf/descriptor.proto |
Jon Skeet | b1a395c | 2015-05-15 14:36:07 +0100 | [diff] [blame] | 42 | |
Jon Skeet | 59eeebe | 2015-07-17 08:26:04 +0100 | [diff] [blame] | 43 | $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf/WellKnownTypes \ |
Jon Skeet | 739d13d | 2015-07-14 14:26:31 +0100 | [diff] [blame] | 44 | src/google/protobuf/any.proto \ |
| 45 | src/google/protobuf/api.proto \ |
| 46 | src/google/protobuf/duration.proto \ |
| 47 | src/google/protobuf/empty.proto \ |
| 48 | src/google/protobuf/field_mask.proto \ |
| 49 | src/google/protobuf/source_context.proto \ |
| 50 | src/google/protobuf/struct.proto \ |
| 51 | src/google/protobuf/timestamp.proto \ |
| 52 | src/google/protobuf/type.proto \ |
| 53 | src/google/protobuf/wrappers.proto |
| 54 | |
Jon Skeet | 59eeebe | 2015-07-17 08:26:04 +0100 | [diff] [blame] | 55 | $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ |
Jon Skeet | c128331 | 2015-06-26 10:32:23 +0100 | [diff] [blame] | 56 | src/google/protobuf/map_unittest_proto3.proto \ |
Jon Skeet | eb70bd0 | 2015-06-12 09:53:44 +0100 | [diff] [blame] | 57 | src/google/protobuf/unittest_proto3.proto \ |
| 58 | src/google/protobuf/unittest_import_proto3.proto \ |
Jon Skeet | b2ac868 | 2015-07-15 13:17:42 +0100 | [diff] [blame] | 59 | src/google/protobuf/unittest_import_public_proto3.proto \ |
| 60 | src/google/protobuf/unittest_well_known_types.proto |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 61 | |
Jon Skeet | c128331 | 2015-06-26 10:32:23 +0100 | [diff] [blame] | 62 | |
Jon Skeet | 0f370b4 | 2015-08-03 10:59:27 +0100 | [diff] [blame] | 63 | $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ |
| 64 | csharp/protos/unittest_issues.proto |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 65 | |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 66 | # AddressBook sample protos |
| 67 | $PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ |
| 68 | examples/addressbook.proto |
Jon Skeet | 044c36e | 2015-08-04 09:25:38 +0100 | [diff] [blame] | 69 | |
| 70 | $PROTOC -Iconformance --csharp_out=csharp/src/Google.Protobuf.Conformance \ |
| 71 | conformance/conformance.proto |