Skip to content

Commit

Permalink
Generate *all* protos in the script, applying fixups.
Browse files Browse the repository at this point in the history
We still have some protos which aren't generated how we want them to be:

- Until we have an option to specify the "umbrella" class, DescriptorProtoFile
  will be broken. (The change of name here affects the reflection descriptor,
  which accounts for most of the change. That's easier than trying to work out
  exactly which occurrences of Descriptor need changing though.)
- That change affects UnittestCustomOptions
- Issue protocolbuffers#307 breaks Unittest.cs

After this commit, we don't have the record of the fixups in the files themselves
any more, but one centralized record in the shell script.
  • Loading branch information
jskeet committed May 16, 2015
1 parent 17ca0fe commit b1a395c
Show file tree
Hide file tree
Showing 5 changed files with 32,084 additions and 40,229 deletions.
27 changes: 26 additions & 1 deletion csharp/generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# You first need to make sure protoc has been built (see instructions on
# building protoc in root of this repository)

# 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.

set -ex

# cd to repository root
Expand All @@ -26,7 +36,12 @@ if [ -z "$PROTOC" ]; then
fi

# Descriptor proto
#TODO(jtattermusch): generate descriptor.proto
# TODO(jonskeet): Remove fixup
cp src/google/protobuf/descriptor.proto src/google/protobuf/descriptor_proto_file.proto
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers/DescriptorProtos \
src/google/protobuf/descriptor_proto_file.proto
rm src/google/protobuf/descriptor_proto_file.proto


# ProtocolBuffers.Test protos
$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \
Expand Down Expand Up @@ -63,6 +78,16 @@ $PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffersLite.Test/
csharp/protos/extest/unittest_extras_full.proto \
csharp/protos/extest/unittest_extras_lite.proto

# TODO(jonskeet): Remove fixup; see issue #307
sed -i -e 's/RepeatedFieldsGenerator\.Group/RepeatedFieldsGenerator.Types.Group/g' \
csharp/src/ProtocolBuffers.Test/TestProtos/Unittest.cs \
csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs \
csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs

# TODO(jonskeet): Remove fixup
sed -i -e 's/DescriptorProtos\.Descriptor\./DescriptorProtos.DescriptorProtoFile./g' \
csharp/src/ProtocolBuffers.Test/TestProtos/UnittestCustomOptions.cs

# AddressBook sample protos
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
examples/addressbook.proto
Loading

0 comments on commit b1a395c

Please sign in to comment.