Commits

ken...@google.com@630680e5-0e50-0410-840e-4b1c322b438d  committed 6cdcd22

Allow services with lite runtime when using rpc generator plugin.

  • Participants
  • Parent commits e732f61

Comments (0)

Files changed (2)

File src/google/protobuf/descriptor.cc

 }
 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);

File src/google/protobuf/descriptor_unittest.cc

     "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) {