2015-05-13 03:52:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Generates C# source files from .proto files.
|
|
|
|
# You first need to make sure protoc has been built (see instructions on
|
|
|
|
# building protoc in root of this repository)
|
|
|
|
|
2017-11-10 09:50:02 +00:00
|
|
|
set -e
|
2015-05-13 03:52:28 +00:00
|
|
|
|
|
|
|
# cd to repository root
|
2016-02-15 10:33:13 +00:00
|
|
|
pushd $(dirname $0)/..
|
2015-05-13 03:52:28 +00:00
|
|
|
|
2015-05-14 08:11:57 +00:00
|
|
|
# Protocol buffer compiler to use. If the PROTOC variable is set,
|
|
|
|
# use that. Otherwise, probe for expected locations under both
|
|
|
|
# Windows and Unix.
|
|
|
|
if [ -z "$PROTOC" ]; then
|
|
|
|
# TODO(jonskeet): Use an array and a for loop instead?
|
2015-06-17 14:16:14 +00:00
|
|
|
if [ -x cmake/build/Debug/protoc.exe ]; then
|
|
|
|
PROTOC=cmake/build/Debug/protoc.exe
|
|
|
|
elif [ -x cmake/build/Release/protoc.exe ]; then
|
|
|
|
PROTOC=cmake/build/Release/protoc.exe
|
2015-05-14 08:11:57 +00:00
|
|
|
elif [ -x src/protoc ]; then
|
|
|
|
PROTOC=src/protoc
|
|
|
|
else
|
|
|
|
echo "Unable to find protocol buffer compiler."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-05-13 03:52:28 +00:00
|
|
|
|
2015-09-01 14:05:03 +00:00
|
|
|
# descriptor.proto and well-known types
|
|
|
|
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
|
|
|
|
--csharp_opt=base_namespace=Google.Protobuf \
|
|
|
|
src/google/protobuf/descriptor.proto \
|
2015-07-14 13:26:31 +00:00
|
|
|
src/google/protobuf/any.proto \
|
|
|
|
src/google/protobuf/api.proto \
|
|
|
|
src/google/protobuf/duration.proto \
|
|
|
|
src/google/protobuf/empty.proto \
|
|
|
|
src/google/protobuf/field_mask.proto \
|
|
|
|
src/google/protobuf/source_context.proto \
|
|
|
|
src/google/protobuf/struct.proto \
|
|
|
|
src/google/protobuf/timestamp.proto \
|
|
|
|
src/google/protobuf/type.proto \
|
|
|
|
src/google/protobuf/wrappers.proto
|
|
|
|
|
2017-11-10 09:50:02 +00:00
|
|
|
# Test protos
|
2019-10-30 09:46:24 +00:00
|
|
|
# Note that this deliberately does *not* include old_extensions1.proto
|
|
|
|
# and old_extensions2.proto, which are generated with an older version
|
|
|
|
# of protoc.
|
2019-11-27 00:45:22 +00:00
|
|
|
$PROTOC -Isrc -Icsharp/protos \
|
2019-11-08 14:41:26 +00:00
|
|
|
--csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
|
2018-08-30 13:53:06 +00:00
|
|
|
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
|
|
|
|
--include_source_info \
|
|
|
|
--include_imports \
|
2019-12-03 16:52:24 +00:00
|
|
|
csharp/protos/map_unittest_proto3.proto \
|
|
|
|
csharp/protos/unittest_issues.proto \
|
|
|
|
csharp/protos/unittest_custom_options_proto3.proto \
|
|
|
|
csharp/protos/unittest_proto3.proto \
|
|
|
|
csharp/protos/unittest_import_proto3.proto \
|
|
|
|
csharp/protos/unittest_import_public_proto3.proto \
|
|
|
|
csharp/protos/unittest.proto \
|
|
|
|
csharp/protos/unittest_import.proto \
|
|
|
|
csharp/protos/unittest_import_public.proto \
|
|
|
|
csharp/protos/unittest_issue6936_a.proto \
|
|
|
|
csharp/protos/unittest_issue6936_b.proto \
|
|
|
|
csharp/protos/unittest_issue6936_c.proto \
|
2020-04-30 15:07:11 +00:00
|
|
|
csharp/protos/unittest_selfreferential_options.proto \
|
2019-12-03 16:52:24 +00:00
|
|
|
src/google/protobuf/unittest_well_known_types.proto \
|
|
|
|
src/google/protobuf/test_messages_proto3.proto \
|
2020-04-15 10:57:38 +00:00
|
|
|
src/google/protobuf/test_messages_proto2.proto \
|
|
|
|
src/google/protobuf/unittest_proto3_optional.proto
|
2016-12-03 16:51:25 +00:00
|
|
|
|
2015-05-14 08:11:57 +00:00
|
|
|
# AddressBook sample protos
|
2017-11-10 09:50:02 +00:00
|
|
|
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
|
2015-05-14 08:11:57 +00:00
|
|
|
examples/addressbook.proto
|
2015-08-04 08:25:38 +00:00
|
|
|
|
2016-01-04 14:02:00 +00:00
|
|
|
$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
|
2015-08-04 08:25:38 +00:00
|
|
|
conformance/conformance.proto
|
2019-03-01 16:29:17 +00:00
|
|
|
|
|
|
|
# Benchmark protos
|
|
|
|
$PROTOC -Ibenchmarks \
|
|
|
|
benchmarks/datasets/google_message1/proto3/*.proto \
|
|
|
|
benchmarks/benchmarks.proto \
|
|
|
|
--csharp_out=csharp/src/Google.Protobuf.Benchmarks
|
2019-11-04 10:58:08 +00:00
|
|
|
|
|
|
|
# C# only benchmark protos
|
|
|
|
$PROTOC -Isrc -Icsharp/src/Google.Protobuf.Benchmarks \
|
|
|
|
csharp/src/Google.Protobuf.Benchmarks/*.proto \
|
|
|
|
--csharp_out=csharp/src/Google.Protobuf.Benchmarks
|