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)
|
|
|
|
|
2015-05-15 13:36:07 +00:00
|
|
|
# This script performs a few fix-ups as part of generation. These are:
|
|
|
|
# - descriptor.proto is renamed to descriptor_proto_file.proto before
|
|
|
|
# generation, to avoid the naming collision between the class for the file
|
|
|
|
# descriptor and its Descriptor property
|
|
|
|
# - This change also impacts UnittestCustomOptions, which expects to
|
|
|
|
# use a class of Descriptor when it's actually been renamed to
|
|
|
|
# DescriptorProtoFile.
|
|
|
|
# - Issue 307 (codegen for double-nested types) breaks Unittest.proto and
|
|
|
|
# its lite equivalents.
|
|
|
|
|
2015-05-13 03:52:28 +00:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
# cd to repository root
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
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
|
|
|
|
|
|
|
# Descriptor proto
|
2015-05-15 13:36:07 +00:00
|
|
|
# TODO(jonskeet): Remove fixup
|
|
|
|
cp src/google/protobuf/descriptor.proto src/google/protobuf/descriptor_proto_file.proto
|
2015-07-14 10:13:52 +00:00
|
|
|
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers/Reflection \
|
2015-05-15 13:36:07 +00:00
|
|
|
src/google/protobuf/descriptor_proto_file.proto
|
|
|
|
rm src/google/protobuf/descriptor_proto_file.proto
|
|
|
|
|
2015-07-14 13:26:31 +00:00
|
|
|
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers/WellKnownTypes \
|
|
|
|
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
|
|
|
|
|
2015-05-13 03:52:28 +00:00
|
|
|
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \
|
2015-06-26 09:32:23 +00:00
|
|
|
src/google/protobuf/map_unittest_proto3.proto \
|
2015-06-12 08:53:44 +00:00
|
|
|
src/google/protobuf/unittest_proto3.proto \
|
|
|
|
src/google/protobuf/unittest_import_proto3.proto \
|
|
|
|
src/google/protobuf/unittest_import_public_proto3.proto
|
2015-05-13 03:52:28 +00:00
|
|
|
|
2015-06-26 09:32:23 +00:00
|
|
|
|
2015-05-13 03:52:28 +00:00
|
|
|
$PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \
|
|
|
|
csharp/protos/extest/unittest_issues.proto
|
|
|
|
|
2015-05-14 08:11:57 +00:00
|
|
|
# AddressBook sample protos
|
|
|
|
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
|
|
|
|
examples/addressbook.proto
|