Revert "grpc/compiler: Respect filename suffix and extension during code generation (#7343)" (#7406)

This reverts commit 97e89c5acd.
This commit is contained in:
Derek Bailey
2022-08-05 23:20:33 -07:00
committed by GitHub
parent ebbed05137
commit 359e0f9d66
14 changed files with 25 additions and 13596 deletions

View File

@@ -8,6 +8,7 @@
namespace grpc_cpp_generator {
namespace {
grpc::string message_header_ext() { return "_generated.h"; }
grpc::string service_header_ext() { return ".grpc.fb.h"; }
template<class T> grpc::string as_string(T x) {
@@ -64,7 +65,7 @@ void PrintIncludes(grpc_generator::Printer *printer,
}
grpc::string GetHeaderPrologue(grpc_generator::File *file,
const Parameters &params) {
const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -74,7 +75,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_identifier"] = FilenameIdentifier(file->filename());
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = params.message_header_extension;
vars["message_header_ext"] = file->message_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@@ -1117,7 +1118,7 @@ grpc::string GetHeaderEpilogue(grpc_generator::File *file,
}
grpc::string GetSourcePrologue(grpc_generator::File *file,
const Parameters &params) {
const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1126,8 +1127,8 @@ grpc::string GetSourcePrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = params.message_header_extension;
vars["service_header_ext"] = service_header_ext();
vars["message_header_ext"] = file->message_header_ext();
vars["service_header_ext"] = file->service_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
@@ -1531,8 +1532,9 @@ grpc::string GetSourceEpilogue(grpc_generator::File *file,
return temp;
}
// TODO(mmukhi): Make sure we need parameters or not.
grpc::string GetMockPrologue(grpc_generator::File *file,
const Parameters &params) {
const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -1541,7 +1543,7 @@ grpc::string GetMockPrologue(grpc_generator::File *file,
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = params.message_header_extension;
vars["message_header_ext"] = message_header_ext();
vars["service_header_ext"] = service_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");

View File

@@ -33,8 +33,6 @@ struct Parameters {
grpc::string grpc_search_path;
// Generate GMOCK code to facilitate unit testing.
bool generate_mock_code;
// By default, use "_generated.h"
std::string message_header_extension;
};
// Return the prologue of the generated header file.

View File

@@ -107,6 +107,8 @@ struct File : public CommentHolder {
virtual grpc::string package() const = 0;
virtual std::vector<grpc::string> package_parts() const = 0;
virtual grpc::string additional_headers() const = 0;
virtual std::string message_header_ext() const = 0;
virtual std::string service_header_ext() const = 0;
virtual int service_count() const = 0;
virtual std::unique_ptr<const Service> service(int i) const = 0;