Revert "[objc] Switch to forward declare proto & clean up (#27444)" (#27521)

This reverts commit 4ad495420f.
reviewable/pr26779/r6
Denny C. Dai 3 years ago committed by GitHub
parent 550faa6dc7
commit 9870583cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      bazel/objc_grpc_library.bzl
  2. 22
      src/compiler/objective_c_plugin.cc
  3. 1
      src/objective-c/grpc_objc_internal_library.bzl
  4. 2
      src/objective-c/tests/RemoteTestClient/RemoteTest.podspec
  5. 2
      test/cpp/ios/RemoteTestClientCpp/RemoteTestCpp.podspec

@ -67,6 +67,7 @@ def objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kw
srcs = arc_srcs,
defines = [
"GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0",
"GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0",
],
includes = [
"_generated_protos",

@ -132,6 +132,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
static const ::std::string kNonNullBegin = "NS_ASSUME_NONNULL_BEGIN\n";
static const ::std::string kNonNullEnd = "NS_ASSUME_NONNULL_END\n";
static const ::std::string kProtocolOnly = "GPB_GRPC_PROTOCOL_ONLY";
static const ::std::string kForwardDeclare =
"GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO";
::std::string file_name =
google::protobuf::compiler::objectivec::FilePath(file);
@ -161,6 +163,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
{
// Generate .pbrpc.h
::std::string imports;
if (framework.empty()) {
imports = LocalImport(file_name + ".pbobjc.h");
} else {
imports = FrameworkImport(file_name + ".pbobjc.h", framework);
}
::std::string system_imports;
if (grpc_local_import) {
system_imports =
@ -200,6 +209,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
::std::string class_declarations =
grpc_objective_c_generator::GetAllMessageClasses(file);
::std::string class_imports;
for (int i = 0; i < file->dependency_count(); i++) {
class_imports += ImportProtoHeaders(
file->dependency(i), " ", framework, pb_runtime_import_prefix);
}
::std::string ng_protocols;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor* service = file->service(i);
@ -222,9 +237,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
Write(context, file_name + ".pbrpc.h",
file_header + SystemImport("Foundation/Foundation.h") + "\n" +
PreprocIfNot(kForwardDeclare, imports) + "\n" +
PreprocIfNot(kProtocolOnly, system_imports) + "\n" +
class_declarations + "\n" + forward_declarations + "\n" +
kNonNullBegin + "\n" + ng_protocols + protocols + "\n" +
class_declarations + "\n" +
PreprocIfNot(kForwardDeclare, class_imports) + "\n" +
forward_declarations + "\n" + kNonNullBegin + "\n" +
ng_protocols + protocols + "\n" +
PreprocIfNot(kProtocolOnly, interfaces) + "\n" + kNonNullEnd +
"\n");
}

@ -166,6 +166,7 @@ def local_objc_grpc_library(name, deps, testing = True, srcs = [], use_well_know
srcs = arc_srcs,
defines = [
"GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=0",
"GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=0",
],
includes = ["_generated_protos"],
deps = library_deps,

@ -49,7 +49,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
# This is needed by all pods that depend on Protobuf:
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1',
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
}

@ -38,7 +38,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
# This is needed by all pods that depend on Protobuf:
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1',
# This is needed by all pods that depend on gRPC-RxLibrary:
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
}

Loading…
Cancel
Save