Skip to content

Commit

Permalink
cleanup(mixin): deduplicate mixin pb headers (#14819)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiy0006 authored Nov 5, 2024
1 parent 7353e6e commit 6ab4a8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion generator/internal/stub_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ Status StubGenerator::GenerateHeader() {
std::vector<std::string> mixin_headers =
absl::StrSplit(vars("mixin_proto_grpc_header_paths"), ',');
HeaderSystemIncludes(mixin_headers);
bool include_lro_header =
HasLongrunningMethod() &&
std::find(mixin_headers.begin(), mixin_headers.end(),
"google/longrunning/operations.grpc.pb.h") ==
mixin_headers.end();
HeaderSystemIncludes(
{vars("proto_grpc_header_path"),
HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "",
include_lro_header ? "google/longrunning/operations.grpc.pb.h" : "",
"memory", "utility"});

auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
Expand Down
14 changes: 9 additions & 5 deletions generator/internal/stub_rest_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ Status StubRestGenerator::GenerateHeader() {
std::vector<std::string> mixin_headers =
absl::StrSplit(vars("mixin_proto_header_paths"), ',');
HeaderSystemIncludes(mixin_headers);
HeaderSystemIncludes({vars("proto_header_path"),
HasLongrunningMethod()
? vars("longrunning_operation_include_header")
: "",
"memory"});
bool include_lro_header =
HasLongrunningMethod() &&
std::find(mixin_headers.begin(), mixin_headers.end(),
vars("longrunning_operation_include_header")) ==
mixin_headers.end();
HeaderSystemIncludes(
{vars("proto_header_path"),
include_lro_header ? vars("longrunning_operation_include_header") : "",
"memory"});

auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
if (!result.ok()) return result;
Expand Down

0 comments on commit 6ab4a8c

Please sign in to comment.