Skip to content

Commit 8bada09

Browse files
authored
impl(generator): add toggle for how proto includes are generated (#15116)
1 parent 7595793 commit 8bada09

15 files changed

+96
-65
lines changed

generator/internal/auth_decorator_generator.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ Status AuthDecoratorGenerator::GenerateHeader() {
5151
HeaderLocalIncludes({vars("stub_header_path"),
5252
"google/cloud/internal/unified_grpc_credentials.h",
5353
"google/cloud/version.h"});
54-
HeaderSystemIncludes(
55-
{HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "",
56-
"memory", "set", "string"});
54+
HeaderProtobufGenCodeIncludes({HasLongrunningMethod()
55+
? "google/longrunning/operations.grpc.pb.h"
56+
: ""});
57+
HeaderSystemIncludes({"memory", "set", "string"});
5758

5859
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
5960
if (!result.ok()) return result;
@@ -110,7 +111,8 @@ Status AuthDecoratorGenerator::GenerateCc() {
110111
? "google/cloud/internal/streaming_write_rpc_impl.h"
111112
: "",
112113
});
113-
CcSystemIncludes({vars("proto_grpc_header_path"), "memory", "utility"});
114+
CcProtobufGenCodeIncludes({vars("proto_grpc_header_path")});
115+
CcSystemIncludes({"memory", "utility"});
114116

115117
auto result = CcOpenNamespaces(NamespaceType::kInternal);
116118
if (!result.ok()) return result;

generator/internal/client_generator.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ Status ClientGenerator::GenerateHeader() {
8888
if (get_iam_policy_extension_ && set_iam_policy_extension_) {
8989
HeaderLocalIncludes({"google/cloud/iam_updater.h"});
9090
}
91-
HeaderSystemIncludes(MethodSignatureWellKnownProtobufTypeIncludes());
91+
HeaderProtobufGenCodeIncludes(MethodSignatureWellKnownProtobufTypeIncludes());
92+
HeaderProtobufGenCodeIncludes({HasGRPCLongrunningOperation()
93+
? "google/longrunning/operations.grpc.pb.h"
94+
: ""});
9295
HeaderSystemIncludes(
93-
{HasGRPCLongrunningOperation() ? "google/longrunning/operations.grpc.pb.h"
94-
: "",
95-
HasMessageWithMapField() ? "map" : "", "memory", "string"});
96+
{HasMessageWithMapField() ? "map" : "", "memory", "string"});
9697

9798
auto result = HeaderOpenNamespaces();
9899
if (!result.ok()) return result;

generator/internal/connection_generator.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Status ConnectionGenerator::GenerateHeader() {
7373
"google/cloud/version.h"});
7474
std::vector<std::string> const additional_pb_header_paths =
7575
absl::StrSplit(vars("additional_pb_header_paths"), absl::ByChar(','));
76-
HeaderSystemIncludes(additional_pb_header_paths);
77-
HeaderSystemIncludes({vars("proto_header_path"),
78-
HasGRPCLongrunningOperation()
79-
? "google/longrunning/operations.grpc.pb.h"
80-
: "",
81-
"memory"});
76+
HeaderProtobufGenCodeIncludes(additional_pb_header_paths);
77+
HeaderProtobufGenCodeIncludes({vars("proto_header_path")});
78+
HeaderProtobufGenCodeIncludes({HasGRPCLongrunningOperation()
79+
? "google/longrunning/operations.grpc.pb.h"
80+
: ""});
81+
HeaderSystemIncludes({"memory"});
8282
switch (endpoint_location_style) {
8383
case ServiceConfiguration::LOCATION_DEPENDENT:
8484
case ServiceConfiguration::LOCATION_DEPENDENT_COMPAT:

generator/internal/connection_impl_generator.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ Status ConnectionImplGenerator::GenerateHeader() {
7575
? "google/cloud/stream_range.h"
7676
: "",
7777
"google/cloud/version.h"});
78-
HeaderSystemIncludes(
79-
{HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "",
80-
"memory"});
78+
HeaderProtobufGenCodeIncludes({HasLongrunningMethod()
79+
? "google/longrunning/operations.grpc.pb.h"
80+
: ""});
81+
HeaderSystemIncludes({"memory"});
8182

8283
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
8384
if (!result.ok()) return result;

generator/internal/connection_impl_rest_generator.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Status ConnectionImplRestGenerator::GenerateHeader() {
5757
"google/cloud/status_or.h",
5858
HasPaginatedMethod() ? "google/cloud/stream_range.h" : "",
5959
"google/cloud/version.h"});
60-
HeaderSystemIncludes({HasLongrunningMethod()
61-
? vars("longrunning_operation_include_header")
62-
: "",
63-
"memory"});
60+
HeaderProtobufGenCodeIncludes(
61+
{HasLongrunningMethod() ? vars("longrunning_operation_include_header")
62+
: ""});
63+
HeaderSystemIncludes({"memory"});
6464

6565
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
6666
if (!result.ok()) return result;

generator/internal/idempotency_policy_generator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ Status IdempotencyPolicyGenerator::GenerateHeader() {
5454
HeaderLocalIncludes({"google/cloud/idempotency.h", "google/cloud/version.h"});
5555

5656
auto headers = GetMixinPbIncludeByTransport();
57-
headers.insert(headers.end(), {GetPbIncludeByTransport(), "memory"});
58-
HeaderSystemIncludes(headers);
57+
headers.insert(headers.end(), {GetPbIncludeByTransport()});
58+
HeaderProtobufGenCodeIncludes(headers);
59+
HeaderSystemIncludes({"memory"});
5960

6061
auto result = HeaderOpenNamespaces();
6162
if (!result.ok()) return result;

generator/internal/logging_decorator_generator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ Status LoggingDecoratorGenerator::GenerateHeader() {
5959
HeaderLocalIncludes({vars("stub_header_path"),
6060
"google/cloud/tracing_options.h",
6161
"google/cloud/version.h"});
62-
HeaderSystemIncludes(
63-
{HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "",
64-
"memory", "set", "string"});
62+
HeaderProtobufGenCodeIncludes({HasLongrunningMethod()
63+
? "google/longrunning/operations.grpc.pb.h"
64+
: ""});
65+
HeaderSystemIncludes({"memory", "set", "string"});
6566

6667
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
6768
if (!result.ok()) return result;
@@ -124,8 +125,8 @@ Status LoggingDecoratorGenerator::GenerateCc() {
124125
? "google/cloud/internal/async_streaming_write_rpc_logging.h"
125126
: "",
126127
"google/cloud/status_or.h"});
127-
CcSystemIncludes(
128-
{vars("proto_grpc_header_path"), "memory", "set", "string", "utility"});
128+
CcProtobufGenCodeIncludes({vars("proto_grpc_header_path")});
129+
CcSystemIncludes({"memory", "set", "string", "utility"});
129130

130131
auto result = CcOpenNamespaces(NamespaceType::kInternal);
131132
if (!result.ok()) return result;

generator/internal/logging_decorator_rest_generator.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ Status LoggingDecoratorRestGenerator::GenerateHeader() {
5353
{vars("stub_rest_header_path"), "google/cloud/internal/rest_context.h",
5454
"google/cloud/future.h", "google/cloud/tracing_options.h",
5555
"google/cloud/version.h"});
56-
HeaderSystemIncludes({vars("proto_header_path"),
57-
HasLongrunningMethod()
58-
? vars("longrunning_operation_include_header")
59-
: "",
60-
"memory", "set", "string"});
56+
HeaderProtobufGenCodeIncludes(
57+
{vars("proto_header_path"),
58+
HasLongrunningMethod() ? vars("longrunning_operation_include_header")
59+
: ""});
60+
HeaderSystemIncludes({"memory", "set", "string"});
6161

6262
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
6363
if (!result.ok()) return result;

generator/internal/metadata_decorator_generator.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ Status MetadataDecoratorGenerator::GenerateHeader() {
129129
HeaderPrint("\n");
130130
HeaderLocalIncludes({vars("stub_header_path"), "google/cloud/options.h",
131131
"google/cloud/version.h"});
132-
HeaderSystemIncludes(
133-
{HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "",
134-
"map", "memory", "string"});
132+
HeaderProtobufGenCodeIncludes({HasLongrunningMethod()
133+
? "google/longrunning/operations.grpc.pb.h"
134+
: ""});
135+
HeaderSystemIncludes({"map", "memory", "string"});
135136

136137
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
137138
if (!result.ok()) return result;
@@ -190,8 +191,8 @@ Status MetadataDecoratorGenerator::GenerateCc() {
190191
HasExplicitRoutingMethod() ? "google/cloud/internal/routing_matcher.h"
191192
: "",
192193
"google/cloud/status_or.h", "google/cloud/internal/url_encode.h"});
193-
CcSystemIncludes({vars("proto_grpc_header_path"), "memory", "string",
194-
"utility", "vector"});
194+
CcProtobufGenCodeIncludes({vars("proto_grpc_header_path")});
195+
CcSystemIncludes({"memory", "string", "utility", "vector"});
195196

196197
auto result = CcOpenNamespaces(NamespaceType::kInternal);
197198
if (!result.ok()) return result;

generator/internal/metadata_decorator_rest_generator.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ Status MetadataDecoratorRestGenerator::GenerateHeader() {
118118
HeaderLocalIncludes({vars("stub_rest_header_path"), "google/cloud/future.h",
119119
"google/cloud/rest_options.h",
120120
"google/cloud/version.h"});
121-
HeaderSystemIncludes({vars("proto_header_path"),
122-
HasLongrunningMethod()
123-
? vars("longrunning_operation_include_header")
124-
: "",
125-
"memory", "string"});
121+
HeaderProtobufGenCodeIncludes(
122+
{vars("proto_header_path"),
123+
HasLongrunningMethod() ? vars("longrunning_operation_include_header")
124+
: ""});
125+
HeaderSystemIncludes({"memory", "string"});
126126

127127
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
128128
if (!result.ok()) return result;

0 commit comments

Comments
 (0)