From 0045e27bf93e4376363a86a6ce8bc7d13565b1da Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 4 Jan 2022 12:53:31 -0500 Subject: [PATCH] Allow optional building in of objc prefix validation. (#28388) --- src/compiler/objective_c_plugin.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 8cc3fdfe172..65807dc98d8 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -29,6 +29,9 @@ using ::google::protobuf::compiler::objectivec:: IsProtobufLibraryBundledProtoFile; using ::google::protobuf::compiler::objectivec::ProtobufLibraryFrameworkName; +#ifdef SUPPORT_OBJC_PREFIX_VALIDATION +using ::google::protobuf::compiler::objectivec::ValidateObjCClassPrefixes; +#endif using ::grpc_objective_c_generator::FrameworkImport; using ::grpc_objective_c_generator::LocalImport; using ::grpc_objective_c_generator::PreprocIfElse; @@ -90,6 +93,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } +#ifdef SUPPORT_OBJC_PREFIX_VALIDATION + // Default options will use env variables for controls. + if (!ValidateObjCClassPrefixes({file}, {}, error)) { + return false; + } +#endif + bool grpc_local_import = false; ::std::string framework; ::std::string pb_runtime_import_prefix;