Skip to content

Commit d10f8bf

Browse files
authored
refactor(generator): use common version and inline namespace for generated code (#5174)
* refactor(generator): use common version and inline namespace for generated code
1 parent b8c48d1 commit d10f8bf

34 files changed

+157
-195
lines changed

generator/integration_tests/golden/BUILD

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ filegroup(
2323
srcs = [
2424
"connection_options.gcpcxx.pb.cc",
2525
"connection_options.gcpcxx.pb.h",
26-
"version.cc",
27-
"version.h",
28-
"version_info.h",
2926
],
3027
)
3128

generator/integration_tests/golden/CMakeLists.txt

+2-8
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ set(google_cloud_cpp_generator_golden_files
2525
internal/database_admin_stub.gcpcxx.pb.cc
2626
internal/database_admin_stub.gcpcxx.pb.h
2727
internal/database_admin_stub_factory.gcpcxx.pb.cc
28-
internal/database_admin_stub_factory.gcpcxx.pb.h
29-
version.cc
30-
version.h
31-
version_info.h)
28+
internal/database_admin_stub_factory.gcpcxx.pb.h)
3229

3330
# Export the list of golden files to a .bzl file so we do not need to maintain
3431
# the list in multiple places.
@@ -47,10 +44,7 @@ add_library(
4744
internal/database_admin_stub.gcpcxx.pb.cc
4845
internal/database_admin_stub.gcpcxx.pb.h
4946
internal/database_admin_stub_factory.gcpcxx.pb.cc
50-
internal/database_admin_stub_factory.gcpcxx.pb.h
51-
version.cc
52-
version.h
53-
version_info.h)
47+
internal/database_admin_stub_factory.gcpcxx.pb.h)
5448

5549
target_include_directories(
5650
google_cloud_cpp_generator_golden_lib

generator/integration_tests/golden/connection_options.gcpcxx.pb.cc

+4-9
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,25 @@
1717
// source: generator/integration_tests/test.proto
1818

1919
#include "generator/integration_tests/golden/connection_options.gcpcxx.pb.h"
20-
#include "absl/strings/str_cat.h"
21-
#include "google/cloud/internal/compiler_info.h"
20+
#include "google/cloud/internal/user_agent_prefix.h"
2221
#include <string>
2322

2423
namespace google {
2524
namespace cloud {
2625
namespace golden {
27-
inline namespace GOLDEN_CLIENT_NS {
26+
inline namespace GOOGLE_CLOUD_CPP_NS {
2827

2928
std::string ConnectionOptionsTraits::default_endpoint() {
3029
return "test.googleapis.com";
3130
}
3231

3332
std::string ConnectionOptionsTraits::user_agent_prefix() {
34-
return absl::StrCat("gcloud-cpp/",
35-
VersionString(), " (",
36-
google::cloud::internal::CompilerId(), "-",
37-
google::cloud::internal::CompilerVersion(), "; ",
38-
google::cloud::internal::CompilerFeatures(), ")");
33+
return google::cloud::internal::UserAgentPrefix();
3934
}
4035

4136
int ConnectionOptionsTraits::default_num_channels() { return 4; }
4237

43-
} // namespace GOLDEN_CLIENT_NS
38+
} // namespace GOOGLE_CLOUD_CPP_NS
4439
} // namespace golden
4540
} // namespace cloud
4641
} // namespace google

generator/integration_tests/golden/connection_options.gcpcxx.pb.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_CONNECTION_OPTIONS_GCPCXX_PB_H
1919
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_CONNECTION_OPTIONS_GCPCXX_PB_H
2020

21-
#include "generator/integration_tests/golden/version.h"
2221
#include "google/cloud/connection_options.h"
22+
#include "google/cloud/version.h"
2323
#include <string>
2424

2525
namespace google {
2626
namespace cloud {
2727
namespace golden {
28-
inline namespace GOLDEN_CLIENT_NS {
28+
inline namespace GOOGLE_CLOUD_CPP_NS {
2929

3030
struct ConnectionOptionsTraits {
3131
static std::string default_endpoint();
@@ -36,7 +36,7 @@ struct ConnectionOptionsTraits {
3636
using ConnectionOptions =
3737
google::cloud::ConnectionOptions<ConnectionOptionsTraits>;
3838

39-
} // namespace GOLDEN_CLIENT_NS
39+
} // namespace GOOGLE_CLOUD_CPP_NS
4040
} // namespace golden
4141
} // namespace cloud
4242
} // namespace google

generator/integration_tests/golden/golden_connection_options_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace google {
2020
namespace cloud {
2121
namespace golden {
22-
inline namespace GOLDEN_CLIENT_NS {
22+
inline namespace GOOGLE_CLOUD_CPP_NS {
2323
namespace {
2424

2525
using ::testing::HasSubstr;
@@ -40,7 +40,7 @@ TEST(GoldenConnectionOptionsTest, DefaultNumChannels) {
4040
}
4141

4242
} // namespace
43-
} // namespace GOLDEN_CLIENT_NS
43+
} // namespace GOOGLE_CLOUD_CPP_NS
4444
} // namespace golden
4545
} // namespace cloud
4646
} // namespace google

generator/integration_tests/golden/golden_logging_decorator_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace google {
2222
namespace cloud {
2323
namespace golden_internal {
24-
inline namespace GOLDEN_CLIENT_NS {
24+
inline namespace GOOGLE_CLOUD_CPP_NS {
2525
namespace {
2626

2727
using ::testing::_;
@@ -475,7 +475,7 @@ TEST_F(LoggingDecoratorTest, CancelOperation) {
475475
}
476476

477477
} // namespace
478-
} // namespace GOLDEN_CLIENT_NS
478+
} // namespace GOOGLE_CLOUD_CPP_NS
479479
} // namespace golden_internal
480480
} // namespace cloud
481481
} // namespace google

generator/integration_tests/golden/golden_metadata_decorator_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace google {
2222
namespace cloud {
2323
namespace golden_internal {
24-
inline namespace GOLDEN_CLIENT_NS {
24+
inline namespace GOOGLE_CLOUD_CPP_NS {
2525
namespace {
2626

2727
using ::google::cloud::testing_util::IsContextMDValid;
@@ -565,7 +565,7 @@ TEST_F(MetadataDecoratorTest, CancelOperation) {
565565
}
566566

567567
} // namespace
568-
} // namespace GOLDEN_CLIENT_NS
568+
} // namespace GOOGLE_CLOUD_CPP_NS
569569
} // namespace golden_internal
570570
} // namespace cloud
571571
} // namespace google

generator/integration_tests/golden/golden_stub_factory_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace google {
2121
namespace cloud {
2222
namespace golden_internal {
23-
inline namespace GOLDEN_CLIENT_NS {
23+
inline namespace GOOGLE_CLOUD_CPP_NS {
2424
namespace {
2525

2626
using ::testing::HasSubstr;
@@ -64,7 +64,7 @@ TEST_F(GoldenStubFactoryTest, DefaultStubWithLogging) {
6464
}
6565

6666
} // namespace
67-
} // namespace GOLDEN_CLIENT_NS
67+
} // namespace GOOGLE_CLOUD_CPP_NS
6868
} // namespace golden_internal
6969
} // namespace cloud
7070
} // namespace google

generator/integration_tests/golden/golden_stub_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using ::testing::Return;
2222
namespace google {
2323
namespace cloud {
2424
namespace golden_internal {
25-
inline namespace GOLDEN_CLIENT_NS {
25+
inline namespace GOOGLE_CLOUD_CPP_NS {
2626
namespace {
2727

2828
class MockGrpcDatabaseAdminStub
@@ -817,7 +817,7 @@ TEST_F(GoldenStubTest, CancelOperation) {
817817
}
818818

819819
} // namespace
820-
} // namespace GOLDEN_CLIENT_NS
820+
} // namespace GOOGLE_CLOUD_CPP_NS
821821
} // namespace golden_internal
822822
} // namespace cloud
823823
} // namespace google

generator/integration_tests/golden/google_cloud_cpp_generator_golden_files.bzl

-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,4 @@ google_cloud_cpp_generator_golden_files = [
2727
"internal/database_admin_stub.gcpcxx.pb.h",
2828
"internal/database_admin_stub_factory.gcpcxx.pb.cc",
2929
"internal/database_admin_stub_factory.gcpcxx.pb.h",
30-
"version.cc",
31-
"version.h",
32-
"version_info.h",
3330
]

generator/integration_tests/golden/internal/database_admin_logging_decorator.gcpcxx.pb.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace google {
2828
namespace cloud {
2929
namespace golden_internal {
30-
inline namespace GOLDEN_CLIENT_NS {
30+
inline namespace GOOGLE_CLOUD_CPP_NS {
3131

3232
DatabaseAdminLogging::DatabaseAdminLogging(
3333
std::shared_ptr<DatabaseAdminStub> child,
@@ -259,7 +259,7 @@ Status DatabaseAdminLogging::CancelOperation(
259259
},
260260
context, request, __func__, tracing_options_);
261261
}
262-
} // namespace GOLDEN_CLIENT_NS
262+
} // namespace GOOGLE_CLOUD_CPP_NS
263263
} // namespace golden_internal
264264
} // namespace cloud
265265
} // namespace google

generator/integration_tests/golden/internal/database_admin_logging_decorator.gcpcxx.pb.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_INTERNAL_DATABASE_ADMIN_LOGGING_DECORATOR_GCPCXX_PB_H
2020

2121
#include "generator/integration_tests/golden/internal/database_admin_stub.gcpcxx.pb.h"
22-
#include "generator/integration_tests/golden/version.h"
2322
#include "google/cloud/tracing_options.h"
23+
#include "google/cloud/version.h"
2424
#include <memory>
2525
#include <string>
2626
namespace google {
2727
namespace cloud {
2828
namespace golden_internal {
29-
inline namespace GOLDEN_CLIENT_NS {
29+
inline namespace GOOGLE_CLOUD_CPP_NS {
3030

3131
class DatabaseAdminLogging : public DatabaseAdminStub {
3232
public:
@@ -117,7 +117,7 @@ class DatabaseAdminLogging : public DatabaseAdminStub {
117117
TracingOptions tracing_options_;
118118
}; // DatabaseAdminLogging
119119

120-
} // namespace GOLDEN_CLIENT_NS
120+
} // namespace GOOGLE_CLOUD_CPP_NS
121121
} // namespace golden_internal
122122
} // namespace cloud
123123
} // namespace google

generator/integration_tests/golden/internal/database_admin_metadata_decorator.gcpcxx.pb.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace google {
2828
namespace cloud {
2929
namespace golden_internal {
30-
inline namespace GOLDEN_CLIENT_NS {
30+
inline namespace GOOGLE_CLOUD_CPP_NS {
3131

3232
namespace {
3333
std::string ApiClientHeader() {
@@ -199,7 +199,7 @@ void DatabaseAdminMetadata::SetMetadata(grpc::ClientContext& context,
199199
context.AddMetadata("x-goog-api-client", api_client_header_);
200200
}
201201

202-
} // namespace GOLDEN_CLIENT_NS
202+
} // namespace GOOGLE_CLOUD_CPP_NS
203203
} // namespace golden_internal
204204
} // namespace cloud
205205
} // namespace google

generator/integration_tests/golden/internal/database_admin_metadata_decorator.gcpcxx.pb.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_INTERNAL_DATABASE_ADMIN_METADATA_DECORATOR_GCPCXX_PB_H
2020

2121
#include "generator/integration_tests/golden/internal/database_admin_stub.gcpcxx.pb.h"
22-
#include "generator/integration_tests/golden/version.h"
2322
#include "google/cloud/tracing_options.h"
23+
#include "google/cloud/version.h"
2424
#include <memory>
2525
#include <string>
2626
namespace google {
2727
namespace cloud {
2828
namespace golden_internal {
29-
inline namespace GOLDEN_CLIENT_NS {
29+
inline namespace GOOGLE_CLOUD_CPP_NS {
3030

3131
class DatabaseAdminMetadata : public DatabaseAdminStub {
3232
public:
@@ -118,7 +118,7 @@ class DatabaseAdminMetadata : public DatabaseAdminStub {
118118
std::string api_client_header_;
119119
}; // DatabaseAdminMetadata
120120

121-
} // namespace GOLDEN_CLIENT_NS
121+
} // namespace GOOGLE_CLOUD_CPP_NS
122122
} // namespace golden_internal
123123
} // namespace cloud
124124
} // namespace google

generator/integration_tests/golden/internal/database_admin_stub.gcpcxx.pb.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
namespace google {
2727
namespace cloud {
2828
namespace golden_internal {
29-
inline namespace GOLDEN_CLIENT_NS {
29+
inline namespace GOOGLE_CLOUD_CPP_NS {
3030

3131
DatabaseAdminStub::~DatabaseAdminStub() = default;
3232

@@ -276,7 +276,7 @@ Status DefaultDatabaseAdminStub::CancelOperation(
276276
}
277277
return google::cloud::Status();
278278
}
279-
} // namespace GOLDEN_CLIENT_NS
279+
} // namespace GOOGLE_CLOUD_CPP_NS
280280
} // namespace golden_internal
281281
} // namespace cloud
282282
} // namespace google

generator/integration_tests/golden/internal/database_admin_stub.gcpcxx.pb.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
#ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_INTERNAL_DATABASE_ADMIN_STUB_GCPCXX_PB_H
1919
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_INTERNAL_DATABASE_ADMIN_STUB_GCPCXX_PB_H
2020

21-
#include "generator/integration_tests/golden/version.h"
2221
#include "google/cloud/status_or.h"
22+
#include "google/cloud/version.h"
2323
#include <generator/integration_tests/test.grpc.pb.h>
2424
#include <google/longrunning/operations.grpc.pb.h>
2525
#include <memory>
2626

2727
namespace google {
2828
namespace cloud {
2929
namespace golden_internal {
30-
inline namespace GOLDEN_CLIENT_NS {
30+
inline namespace GOOGLE_CLOUD_CPP_NS {
3131

3232
class DatabaseAdminStub {
3333
public:
@@ -221,7 +221,7 @@ class DefaultDatabaseAdminStub : public DatabaseAdminStub {
221221
std::unique_ptr<google::longrunning::Operations::StubInterface> operations_;
222222
};
223223

224-
} // namespace GOLDEN_CLIENT_NS
224+
} // namespace GOOGLE_CLOUD_CPP_NS
225225
} // namespace golden_internal
226226
} // namespace cloud
227227
} // namespace google

generator/integration_tests/golden/internal/database_admin_stub_factory.gcpcxx.pb.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
namespace google {
2727
namespace cloud {
2828
namespace golden_internal {
29-
inline namespace GOLDEN_CLIENT_NS {
29+
inline namespace GOOGLE_CLOUD_CPP_NS {
3030

3131
std::shared_ptr<DatabaseAdminStub>
3232
CreateDefaultDatabaseAdminStub(golden::ConnectionOptions const& options) {
@@ -52,7 +52,7 @@ CreateDefaultDatabaseAdminStub(golden::ConnectionOptions const& options) {
5252
return stub;
5353
}
5454

55-
} // namespace GOLDEN_CLIENT_NS
55+
} // namespace GOOGLE_CLOUD_CPP_NS
5656
} // namespace golden_internal
5757
} // namespace cloud
5858
} // namespace google

generator/integration_tests/golden/internal/database_admin_stub_factory.gcpcxx.pb.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020

2121
#include "generator/integration_tests/golden/connection_options.gcpcxx.pb.h"
2222
#include "generator/integration_tests/golden/internal/database_admin_stub.gcpcxx.pb.h"
23-
#include "generator/integration_tests/golden/version.h"
23+
#include "google/cloud/version.h"
2424
#include <memory>
2525

2626
namespace google {
2727
namespace cloud {
2828
namespace golden_internal {
29-
inline namespace GOLDEN_CLIENT_NS {
29+
inline namespace GOOGLE_CLOUD_CPP_NS {
3030

3131
std::shared_ptr<DatabaseAdminStub>
3232
CreateDefaultDatabaseAdminStub(golden::ConnectionOptions const& options);
3333

34-
} // namespace GOLDEN_CLIENT_NS
34+
} // namespace GOOGLE_CLOUD_CPP_NS
3535
} // namespace golden_internal
3636
} // namespace cloud
3737
} // namespace google

0 commit comments

Comments
 (0)