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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 2 additions & 8 deletions
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

Lines changed: 4 additions & 9 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 3 deletions
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
]

0 commit comments

Comments
 (0)