From d09ab8538d5742a149095445c6880382b6b4408d Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Mon, 19 Apr 2010 19:15:12 +0000 Subject: [PATCH] Allow services with lite runtime when using rpc generator plugin. --- src/google/protobuf/descriptor.cc | 8 ++++++-- src/google/protobuf/descriptor_unittest.cc | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 81c4ac0f37..9226dfbcf7 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -3720,10 +3720,14 @@ void DescriptorBuilder::ValidateEnumValueOptions( } void DescriptorBuilder::ValidateServiceOptions(ServiceDescriptor* service, const ServiceDescriptorProto& proto) { - if (IsLite(service->file())) { + if (IsLite(service->file()) && + (service->file()->options().cc_generic_services() || + service->file()->options().java_generic_services())) { AddError(service->full_name(), proto, DescriptorPool::ErrorCollector::NAME, - "Files with optimize_for = LITE_RUNTIME cannot define services."); + "Files with optimize_for = LITE_RUNTIME cannot define services " + "unless you set both options cc_generic_services and " + "java_generic_sevices to false."); } VALIDATE_OPTIONS_FROM_ARRAY(service, method, Method); diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index ec2c815298..d70c9bf11e 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -3487,7 +3487,17 @@ TEST_F(ValidationErrorTest, NoLiteServices) { "service { name: \"Foo\" }", "foo.proto: Foo: NAME: Files with optimize_for = LITE_RUNTIME cannot " - "define services.\n"); + "define services unless you set both options cc_generic_services and " + "java_generic_sevices to false.\n"); + + BuildFile( + "name: \"bar.proto\" " + "options {" + " optimize_for: LITE_RUNTIME" + " cc_generic_services: false" + " java_generic_services: false" + "} " + "service { name: \"Foo\" }"); } TEST_F(ValidationErrorTest, RollbackAfterError) {