Emit additional headers in generated .h file instead of .cc

For Flatbuffers compatibility.

From what I can tell, File::additional_headers is not used by gRPC
itself or its default protobuf implementation; it was added for
Flatbuffers support (it just returns "" for protobuf).

In the Flatbuffer case, the generated header contains references to
Flatbuffer gRPC glue code which is in a header in additional_headers.
Prior to this patch, this meant that the generated .h file could not
be included unless this glue file was included first.

Because the protobuf implementation of additional_headers returns
an empty string, I think this change should be safe to do and not
have unintentional consequences.
pull/11080/head
Per Grön 8 years ago
parent c72b1a312c
commit b50cf568d7
  1. 2
      src/compiler/cpp_generator.cc

@ -125,6 +125,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "\n");
printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
printer->Print(vars, file->additional_headers().c_str());
printer->Print(vars, "\n");
}
return output;
@ -1046,7 +1047,6 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n");
printer->Print(vars, file->additional_headers().c_str());
printer->Print(vars, "\n");
}
return output;

Loading…
Cancel
Save