Skip to content

Commit 0b560df

Browse files
authored
refactor(cloudbuild): versioned clients (#10877)
1 parent 9157786 commit 0b560df

41 files changed

Lines changed: 1701 additions & 1480 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
458 Bytes
Binary file not shown.

ci/etc/expected_install_directories

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@
147147
./include/google/cloud/channel/v1/internal
148148
./include/google/cloud/channel/v1/mocks
149149
./include/google/cloud/cloudbuild
150-
./include/google/cloud/cloudbuild/internal
151150
./include/google/cloud/cloudbuild/mocks
151+
./include/google/cloud/cloudbuild/v1
152+
./include/google/cloud/cloudbuild/v1/internal
153+
./include/google/cloud/cloudbuild/v1/mocks
152154
./include/google/cloud/clouddms
153155
./include/google/cloud/clouddms/v1
154156
./include/google/cloud/composer

generator/generator_config.textproto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ service {
347347
# Cloud Build
348348
service {
349349
service_proto_path: "google/devtools/cloudbuild/v1/cloudbuild.proto"
350-
product_path: "google/cloud/cloudbuild"
350+
product_path: "google/cloud/cloudbuild/v1"
351+
forwarding_product_path: "google/cloud/cloudbuild"
351352
initial_copyright_year: "2022"
352353
retryable_status_codes: ["kUnavailable"]
353354
}

google/cloud/cloudbuild/BUILD.bazel

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@ package(default_visibility = ["//visibility:private"])
1616

1717
licenses(["notice"]) # Apache 2.0
1818

19+
service_dirs = [
20+
"",
21+
"v1/",
22+
]
23+
24+
src_dirs = service_dirs + [d + "internal/" for d in service_dirs]
25+
1926
filegroup(
2027
name = "srcs",
21-
srcs = glob([
22-
"*.cc",
23-
"internal/*.cc",
24-
]),
28+
srcs = glob([d + "*.cc" for d in src_dirs]),
2529
)
2630

2731
filegroup(
2832
name = "hdrs",
29-
srcs = glob([
30-
"*.h",
31-
"internal/*.h",
32-
]),
33+
srcs = glob([d + "*.h" for d in src_dirs]),
3334
)
3435

3536
filegroup(
3637
name = "mocks",
37-
srcs = glob(["mocks/*.h"]),
38+
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
3839
)
3940

4041
cc_library(
@@ -58,3 +59,13 @@ cc_library(
5859
"@com_google_googletest//:gtest",
5960
],
6061
)
62+
63+
[cc_test(
64+
name = sample.replace("/", "_").replace(".cc", ""),
65+
srcs = [sample],
66+
tags = ["integration-test"],
67+
deps = [
68+
"//:cloudbuild",
69+
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
70+
],
71+
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]

google/cloud/cloudbuild/CMakeLists.txt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,22 @@ include(GoogleapisConfig)
1818
set(DOXYGEN_PROJECT_NAME "Cloud Build API C++ Client")
1919
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Cloud Build API")
2020
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
21-
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "cloudbuild_internal"
22-
"cloudbuild_testing" "examples")
23-
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/samples
24-
${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
21+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")
22+
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart")
23+
24+
unset(mocks_globs)
25+
unset(source_globs)
26+
set(service_dirs "" "v1/")
27+
foreach (dir IN LISTS service_dirs)
28+
string(REPLACE "/" "_" ns "${dir}")
29+
list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*")
30+
list(APPEND mocks_globs "${dir}mocks/*.h")
31+
list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "cloudbuild_${ns}internal")
32+
if (NOT dir STREQUAL "")
33+
list(APPEND DOXYGEN_EXAMPLE_PATH
34+
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples")
35+
endif ()
36+
endforeach ()
2537

2638
include(GoogleCloudCppDoxygen)
2739
google_cloud_cpp_doxygen_targets("cloudbuild" DEPENDS cloud-docs
@@ -47,7 +59,7 @@ target_link_libraries(google_cloud_cpp_cloudbuild_protos PUBLIC ${proto_deps})
4759
file(
4860
GLOB source_files
4961
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
50-
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
62+
${source_globs})
5163
list(SORT source_files)
5264
add_library(google_cloud_cpp_cloudbuild ${source_files})
5365
target_include_directories(
@@ -77,7 +89,7 @@ add_library(google-cloud-cpp::cloudbuild ALIAS google_cloud_cpp_cloudbuild)
7789
file(
7890
GLOB relative_mock_files
7991
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
80-
"mocks/*.h")
92+
${mocks_globs})
8193
list(SORT relative_mock_files)
8294
set(mock_files)
8395
foreach (file IN LISTS relative_mock_files)
@@ -178,3 +190,10 @@ install(
178190
COMPONENT google_cloud_cpp_development)
179191

180192
external_googleapis_install_pc("google_cloud_cpp_cloudbuild_protos")
193+
194+
# google-cloud-cpp::cloudbuild must be defined before we can add the samples.
195+
foreach (dir IN LISTS service_dirs)
196+
if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
197+
google_cloud_cpp_add_samples_relative("cloudbuild" "${dir}samples/")
198+
endif ()
199+
endforeach ()

0 commit comments

Comments
 (0)