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. |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 14 | PROTOC_LOCATIONS=( |
| 15 | "bazel-bin/protoc" |
| 16 | "solution/Debug/protoc.exe" |
| 17 | "cmake/build/Debug/protoc.exe" |
| 18 | "cmake/build/Release/protoc.exe" |
| 19 | ) |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 20 | if [ -z "$PROTOC" ]; then |
Mike Kruskal | ed5c57a | 2022-08-10 22:51:29 -0700 | [diff] [blame] | 21 | for protoc in "${PROTOC_LOCATIONS[@]}"; do |
| 22 | if [ -x "$protoc" ]; then |
| 23 | PROTOC="$protoc" |
| 24 | fi |
| 25 | done |
| 26 | if [ -z "$PROTOC" ]; then |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 27 | echo "Unable to find protocol buffer compiler." |
| 28 | exit 1 |
| 29 | fi |
| 30 | fi |
Jan Tattermusch | dfefe9a | 2015-05-12 20:52:28 -0700 | [diff] [blame] | 31 | |
Jon Skeet | 5eb1fac | 2015-09-01 15:05:03 +0100 | [diff] [blame] | 32 | # descriptor.proto and well-known types |
| 33 | $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ |
| 34 | --csharp_opt=base_namespace=Google.Protobuf \ |
Jon Skeet | 5c6c868 | 2022-10-25 16:13:27 +0100 | [diff] [blame] | 35 | --csharp_opt=file_extension=.pb.cs \ |
Jon Skeet | 5eb1fac | 2015-09-01 15:05:03 +0100 | [diff] [blame] | 36 | src/google/protobuf/descriptor.proto \ |
Jon Skeet | 739d13d | 2015-07-14 14:26:31 +0100 | [diff] [blame] | 37 | src/google/protobuf/any.proto \ |
| 38 | src/google/protobuf/api.proto \ |
| 39 | src/google/protobuf/duration.proto \ |
| 40 | src/google/protobuf/empty.proto \ |
| 41 | src/google/protobuf/field_mask.proto \ |
| 42 | src/google/protobuf/source_context.proto \ |
| 43 | src/google/protobuf/struct.proto \ |
| 44 | src/google/protobuf/timestamp.proto \ |
| 45 | src/google/protobuf/type.proto \ |
Jon Skeet | 54101ec | 2022-07-12 10:27:57 +0100 | [diff] [blame] | 46 | src/google/protobuf/wrappers.proto \ |
| 47 | src/google/protobuf/compiler/plugin.proto |
Jon Skeet | 739d13d | 2015-07-14 14:26:31 +0100 | [diff] [blame] | 48 | |
Jon Skeet | aa77eab | 2017-11-10 09:50:02 +0000 | [diff] [blame] | 49 | # Test protos |
Jon Skeet | 7581fd5 | 2019-10-30 09:46:24 +0000 | [diff] [blame] | 50 | # Note that this deliberately does *not* include old_extensions1.proto |
| 51 | # and old_extensions2.proto, which are generated with an older version |
| 52 | # of protoc. |
Protobuf Team Bot | 943bd5a | 2023-01-31 01:30:54 -0800 | [diff] [blame] | 53 | $PROTOC -Isrc -I. \ |
Jon Skeet | d4ec70f | 2020-07-14 05:51:52 +0100 | [diff] [blame] | 54 | --experimental_allow_proto3_optional \ |
Sydney Acksman | b84929f | 2019-11-08 08:41:26 -0600 | [diff] [blame] | 55 | --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \ |
Jon Skeet | 5c6c868 | 2022-10-25 16:13:27 +0100 | [diff] [blame] | 56 | --csharp_opt=file_extension=.pb.cs \ |
Jon Skeet | 1711999 | 2018-08-30 14:53:06 +0100 | [diff] [blame] | 57 | --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ |
| 58 | --include_source_info \ |
| 59 | --include_imports \ |
Sydney Acksman | 367fd27 | 2019-12-03 10:52:24 -0600 | [diff] [blame] | 60 | csharp/protos/map_unittest_proto3.proto \ |
| 61 | csharp/protos/unittest_issues.proto \ |
| 62 | csharp/protos/unittest_custom_options_proto3.proto \ |
| 63 | csharp/protos/unittest_proto3.proto \ |
| 64 | csharp/protos/unittest_import_proto3.proto \ |
| 65 | csharp/protos/unittest_import_public_proto3.proto \ |
| 66 | csharp/protos/unittest.proto \ |
| 67 | csharp/protos/unittest_import.proto \ |
| 68 | csharp/protos/unittest_import_public.proto \ |
| 69 | csharp/protos/unittest_issue6936_a.proto \ |
| 70 | csharp/protos/unittest_issue6936_b.proto \ |
| 71 | csharp/protos/unittest_issue6936_c.proto \ |
Jan Tattermusch | 661c0c4 | 2020-04-30 17:07:11 +0200 | [diff] [blame] | 72 | csharp/protos/unittest_selfreferential_options.proto \ |
Sydney Acksman | 367fd27 | 2019-12-03 10:52:24 -0600 | [diff] [blame] | 73 | src/google/protobuf/unittest_well_known_types.proto \ |
| 74 | src/google/protobuf/test_messages_proto3.proto \ |
Jon Skeet | b0649a0 | 2020-04-15 11:57:38 +0100 | [diff] [blame] | 75 | src/google/protobuf/test_messages_proto2.proto \ |
Adam Cozzette | a2e8a2c | 2023-04-28 16:25:40 -0700 | [diff] [blame] | 76 | src/google/protobuf/unittest_proto3_optional.proto \ |
| 77 | src/google/protobuf/unittest_retention.proto |
Joshua Haberman | f1ce60e | 2016-12-03 11:51:25 -0500 | [diff] [blame] | 78 | |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 79 | # AddressBook sample protos |
Jon Skeet | aa77eab | 2017-11-10 09:50:02 +0000 | [diff] [blame] | 80 | $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ |
Jon Skeet | 5c6c868 | 2022-10-25 16:13:27 +0100 | [diff] [blame] | 81 | --csharp_opt=file_extension=.pb.cs \ |
Jon Skeet | 734393d | 2015-05-14 09:11:57 +0100 | [diff] [blame] | 82 | examples/addressbook.proto |
Jon Skeet | 7ee157b | 2023-02-14 08:54:52 -0800 | [diff] [blame] | 83 | |
| 84 | # Conformance tests |
| 85 | $PROTOC -I. --csharp_out=csharp/src/Google.Protobuf.Conformance \ |
| 86 | --csharp_opt=file_extension=.pb.cs \ |
| 87 | conformance/conformance.proto |