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 | aa77eab | 2017-11-10 09:50:02 +0000 | [diff] [blame] | 6 | set -e |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 7 | |
| 8 | # cd to repository root |
Jon Skeet | 957e877 | 2016-02-15 10:33:13 +0000 | [diff] [blame] | 9 | pushd $(dirname $0)/.. |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 10 | |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 11 | # Protocol buffer compiler to use. If the PROTOC variable is set, |
| 12 | # use that. Otherwise, probe for expected locations under both |
| 13 | # Windows and Unix. |
| 14 | if [ -z "$PROTOC" ]; then |
| 15 | # TODO(jonskeet): Use an array and a for loop instead? |
Jon Skeet | 09f3f4e | 2015-06-17 15:16:14 +0100 | [diff] [blame] | 16 | if [ -x cmake/build/Debug/protoc.exe ]; then |
| 17 | PROTOC=cmake/build/Debug/protoc.exe |
| 18 | elif [ -x cmake/build/Release/protoc.exe ]; then |
| 19 | PROTOC=cmake/build/Release/protoc.exe |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 20 | elif [ -x src/protoc ]; then |
| 21 | PROTOC=src/protoc |
| 22 | else |
| 23 | echo "Unable to find protocol buffer compiler." |
| 24 | exit 1 |
| 25 | fi |
| 26 | fi |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 27 | |
Jon Skeet | 5eb1fac | 2015-09-01 15:05:03 +0100 | [diff] [blame] | 28 | # descriptor.proto and well-known types |
| 29 | $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ |
| 30 | --csharp_opt=base_namespace=Google.Protobuf \ |
| 31 | src/google/protobuf/descriptor.proto \ |
Jon Skeet | 739d13d | 2015-07-14 14:26:31 +0100 | [diff] [blame] | 32 | src/google/protobuf/any.proto \ |
| 33 | src/google/protobuf/api.proto \ |
| 34 | src/google/protobuf/duration.proto \ |
| 35 | src/google/protobuf/empty.proto \ |
| 36 | src/google/protobuf/field_mask.proto \ |
| 37 | src/google/protobuf/source_context.proto \ |
| 38 | src/google/protobuf/struct.proto \ |
| 39 | src/google/protobuf/timestamp.proto \ |
| 40 | src/google/protobuf/type.proto \ |
| 41 | src/google/protobuf/wrappers.proto |
| 42 | |
Jon Skeet | aa77eab | 2017-11-10 09:50:02 +0000 | [diff] [blame] | 43 | # Test protos |
Jon Skeet | 7581fd5 | 2019-10-30 09:46:24 +0000 | [diff] [blame] | 44 | # Note that this deliberately does *not* include old_extensions1.proto |
| 45 | # and old_extensions2.proto, which are generated with an older version |
| 46 | # of protoc. |
Sydney Acksman | 145033c | 2019-11-26 18:45:22 -0600 | [diff] [blame] | 47 | $PROTOC -Isrc -Icsharp/protos \ |
Jon Skeet | d4ec70f | 2020-07-14 05:51:52 +0100 | [diff] [blame] | 48 | --experimental_allow_proto3_optional \ |
Sydney Acksman | b84929f | 2019-11-08 08:41:26 -0600 | [diff] [blame] | 49 | --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \ |
Jon Skeet | 1711999 | 2018-08-30 14:53:06 +0100 | [diff] [blame] | 50 | --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ |
| 51 | --include_source_info \ |
| 52 | --include_imports \ |
Sydney Acksman | 367fd27 | 2019-12-03 10:52:24 -0600 | [diff] [blame] | 53 | csharp/protos/map_unittest_proto3.proto \ |
| 54 | csharp/protos/unittest_issues.proto \ |
| 55 | csharp/protos/unittest_custom_options_proto3.proto \ |
| 56 | csharp/protos/unittest_proto3.proto \ |
| 57 | csharp/protos/unittest_import_proto3.proto \ |
| 58 | csharp/protos/unittest_import_public_proto3.proto \ |
| 59 | csharp/protos/unittest.proto \ |
| 60 | csharp/protos/unittest_import.proto \ |
| 61 | csharp/protos/unittest_import_public.proto \ |
| 62 | csharp/protos/unittest_issue6936_a.proto \ |
| 63 | csharp/protos/unittest_issue6936_b.proto \ |
| 64 | csharp/protos/unittest_issue6936_c.proto \ |
Jan Tattermusch | 661c0c4 | 2020-04-30 17:07:11 +0200 | [diff] [blame] | 65 | csharp/protos/unittest_selfreferential_options.proto \ |
Sydney Acksman | 367fd27 | 2019-12-03 10:52:24 -0600 | [diff] [blame] | 66 | src/google/protobuf/unittest_well_known_types.proto \ |
| 67 | src/google/protobuf/test_messages_proto3.proto \ |
Jon Skeet | b0649a0 | 2020-04-15 11:57:38 +0100 | [diff] [blame] | 68 | src/google/protobuf/test_messages_proto2.proto \ |
| 69 | src/google/protobuf/unittest_proto3_optional.proto |
Joshua Haberman | f1ce60e | 2016-12-03 11:51:25 -0500 | [diff] [blame] | 70 | |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 71 | # AddressBook sample protos |
Jon Skeet | aa77eab | 2017-11-10 09:50:02 +0000 | [diff] [blame] | 72 | $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 73 | examples/addressbook.proto |
Jon Skeet | 044c36e | 2015-08-04 09:25:38 +0100 | [diff] [blame] | 74 | |
Jon Skeet | d49b9c8 | 2016-01-04 14:02:00 +0000 | [diff] [blame] | 75 | $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \ |
Jon Skeet | 044c36e | 2015-08-04 09:25:38 +0100 | [diff] [blame] | 76 | conformance/conformance.proto |
Jon Skeet | 233f486 | 2019-03-01 16:29:17 +0000 | [diff] [blame] | 77 | |
| 78 | # Benchmark protos |
| 79 | $PROTOC -Ibenchmarks \ |
| 80 | benchmarks/datasets/google_message1/proto3/*.proto \ |
| 81 | benchmarks/benchmarks.proto \ |
| 82 | --csharp_out=csharp/src/Google.Protobuf.Benchmarks |
Jan Tattermusch | c81bad1 | 2019-11-04 11:58:08 +0100 | [diff] [blame] | 83 | |
| 84 | # C# only benchmark protos |
| 85 | $PROTOC -Isrc -Icsharp/src/Google.Protobuf.Benchmarks \ |
| 86 | csharp/src/Google.Protobuf.Benchmarks/*.proto \ |
| 87 | --csharp_out=csharp/src/Google.Protobuf.Benchmarks |