Skip to content

Commit e1ef6f4

Browse files
authored
feat(container): generate library (#8109)
1 parent 56ee896 commit e1ef6f4

42 files changed

Lines changed: 6993 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ cc_library(
241241
],
242242
)
243243

244+
cc_library(
245+
name = "experimental-container",
246+
deps = [
247+
"//google/cloud/container:google_cloud_cpp_container",
248+
],
249+
)
250+
251+
cc_library(
252+
name = "experimental-container_mocks",
253+
deps = [
254+
"//google/cloud/container:google_cloud_cpp_container_mocks",
255+
],
256+
)
257+
244258
cc_library(
245259
name = "experimental-containeranalysis",
246260
deps = [

ci/etc/expected_install_directories

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
./include/google/cloud/composer
7474
./include/google/cloud/composer/internal
7575
./include/google/cloud/composer/mocks
76+
./include/google/cloud/container
77+
./include/google/cloud/container/internal
78+
./include/google/cloud/container/mocks
7679
./include/google/cloud/containeranalysis
7780
./include/google/cloud/containeranalysis/internal
7881
./include/google/cloud/containeranalysis/mocks
@@ -275,6 +278,8 @@
275278
./include/google/cloud/workflows/internal
276279
./include/google/cloud/workflows/mocks
277280
./include/google/cloud/workflows/v1
281+
./include/google/container
282+
./include/google/container/v1
278283
./include/google/devtools
279284
./include/google/devtools/artifactregistry
280285
./include/google/devtools/artifactregistry/v1
@@ -331,6 +336,7 @@
331336
./lib64/cmake/google_cloud_cpp_channel
332337
./lib64/cmake/google_cloud_cpp_cloudbuild
333338
./lib64/cmake/google_cloud_cpp_composer
339+
./lib64/cmake/google_cloud_cpp_container
334340
./lib64/cmake/google_cloud_cpp_containeranalysis
335341
./lib64/cmake/google_cloud_cpp_datamigration
336342
./lib64/cmake/google_cloud_cpp_debugger

ci/etc/full_feature_list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ binaryauthorization
1212
channel
1313
cloudbuild
1414
composer
15+
container
1516
containeranalysis
1617
datamigration
1718
debugger
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@com_google_googleapis//google/api:annotations_proto
2+
@com_google_googleapis//google/api:client_proto
3+
@com_google_googleapis//google/api:field_behavior_proto
4+
@com_google_googleapis//google/api:http_proto
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@com_google_googleapis//google/container/v1:cluster_service.proto

external/googleapis/update_libraries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ declare -A -r LIBRARIES=(
5656
["channel"]="@com_google_googleapis//google/cloud/channel/v1:channel_cc_grpc"
5757
["cloudbuild"]="@com_google_googleapis//google/devtools/cloudbuild/v1:cloudbuild_cc_grpc"
5858
["composer"]="@com_google_googleapis//google/cloud/orchestration/airflow/service/v1:service_cc_grpc"
59+
["container"]="@com_google_googleapis//google/container/v1:container_cc_grpc"
5960
["containeranalysis"]="@com_google_googleapis//google/devtools/containeranalysis/v1:containeranalysis_cc_grpc"
6061
["datamigration"]="$(
6162
printf ",%s" \

generator/generator_config.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ service {
202202
retryable_status_codes: ["kUnavailable"]
203203
}
204204

205+
# Container
206+
service {
207+
service_proto_path: "google/container/v1/cluster_service.proto"
208+
product_path: "google/cloud/container"
209+
initial_copyright_year: "2022"
210+
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
211+
}
212+
205213
# Container Analysis
206214
service {
207215
service_proto_path: "google/devtools/containeranalysis/v1/containeranalysis.proto"

google/cloud/container/BUILD.bazel

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
package(default_visibility = ["//visibility:private"])
16+
17+
licenses(["notice"]) # Apache 2.0
18+
19+
SOURCE_GLOB = "**/*.cc"
20+
21+
MOCK_SOURCE_GLOB = "mocks/*.cc"
22+
23+
HEADER_GLOB = "**/*.h"
24+
25+
MOCK_HEADER_GLOB = "mocks/*.h"
26+
27+
cc_library(
28+
name = "google_cloud_cpp_container",
29+
srcs = glob(
30+
include = [SOURCE_GLOB],
31+
exclude = [MOCK_SOURCE_GLOB],
32+
),
33+
hdrs = glob(
34+
include = [HEADER_GLOB],
35+
exclude = [MOCK_HEADER_GLOB],
36+
),
37+
visibility = ["//:__pkg__"],
38+
deps = [
39+
"//google/cloud:google_cloud_cpp_common",
40+
"//google/cloud:google_cloud_cpp_grpc_utils",
41+
"@com_google_googleapis//google/container/v1:container_cc_grpc",
42+
],
43+
)
44+
45+
cc_library(
46+
name = "google_cloud_cpp_container_mocks",
47+
srcs = glob(
48+
include = [MOCK_SOURCE_GLOB],
49+
),
50+
hdrs = glob(
51+
include = [MOCK_HEADER_GLOB],
52+
),
53+
visibility = ["//:__pkg__"],
54+
deps = [
55+
":google_cloud_cpp_container",
56+
"//google/cloud:google_cloud_cpp_common",
57+
"//google/cloud:google_cloud_cpp_grpc_utils",
58+
],
59+
)
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# ~~~
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ~~~
16+
17+
include(GoogleapisConfig)
18+
set(DOXYGEN_PROJECT_NAME "Kubernetes Engine API C++ Client")
19+
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Kubernetes Engine API")
20+
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
21+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "container_internal" "container_testing"
22+
"examples")
23+
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
24+
25+
# Creates the proto headers needed by doxygen.
26+
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::container_protos)
27+
28+
find_package(gRPC REQUIRED)
29+
find_package(ProtobufWithTargets REQUIRED)
30+
find_package(absl CONFIG REQUIRED)
31+
32+
include(GoogleCloudCppCommon)
33+
34+
set(EXTERNAL_GOOGLEAPIS_SOURCE
35+
"${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
36+
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
37+
if (PROTO_INCLUDE_DIR)
38+
list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
39+
endif ()
40+
41+
include(CompileProtos)
42+
google_cloud_cpp_grpcpp_library(
43+
google_cloud_cpp_container_protos
44+
# cmake-format: sort
45+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/container/v1/cluster_service.proto
46+
PROTO_PATH_DIRECTORIES
47+
"${EXTERNAL_GOOGLEAPIS_SOURCE}"
48+
"${PROTO_INCLUDE_DIR}")
49+
external_googleapis_set_version_and_alias(container_protos)
50+
target_link_libraries(
51+
google_cloud_cpp_container_protos
52+
PUBLIC #
53+
google-cloud-cpp::api_annotations_protos
54+
google-cloud-cpp::api_client_protos
55+
google-cloud-cpp::api_field_behavior_protos
56+
google-cloud-cpp::api_http_protos
57+
google-cloud-cpp::rpc_code_protos)
58+
59+
file(
60+
GLOB source_files
61+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
62+
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
63+
list(SORT source_files)
64+
add_library(google_cloud_cpp_container ${source_files})
65+
target_include_directories(
66+
google_cloud_cpp_container
67+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
68+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
69+
$<INSTALL_INTERFACE:include>)
70+
target_link_libraries(
71+
google_cloud_cpp_container
72+
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
73+
google-cloud-cpp::container_protos)
74+
google_cloud_cpp_add_common_options(google_cloud_cpp_container)
75+
set_target_properties(
76+
google_cloud_cpp_container
77+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-container
78+
VERSION "${PROJECT_VERSION}" SOVERSION
79+
"${PROJECT_VERSION_MAJOR}")
80+
target_compile_options(google_cloud_cpp_container
81+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
82+
83+
add_library(google-cloud-cpp::experimental-container ALIAS
84+
google_cloud_cpp_container)
85+
86+
# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
87+
# for these, a regular library would not work on macOS (where the library needs
88+
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
89+
# that they need absolute paths for their sources.
90+
file(
91+
GLOB relative_mock_files
92+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
93+
"mocks/*.h")
94+
list(SORT relative_mock_files)
95+
set(mock_files)
96+
foreach (file IN LISTS relative_mock_files)
97+
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
98+
endforeach ()
99+
add_library(google_cloud_cpp_container_mocks INTERFACE)
100+
target_sources(google_cloud_cpp_container_mocks INTERFACE ${mock_files})
101+
target_link_libraries(
102+
google_cloud_cpp_container_mocks
103+
INTERFACE google-cloud-cpp::experimental-container GTest::gmock_main
104+
GTest::gmock GTest::gtest)
105+
set_target_properties(
106+
google_cloud_cpp_container_mocks
107+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-container_mocks)
108+
target_include_directories(
109+
google_cloud_cpp_container_mocks
110+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
111+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
112+
$<INSTALL_INTERFACE:include>)
113+
target_compile_options(google_cloud_cpp_container_mocks
114+
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
115+
116+
# Get the destination directories based on the GNU recommendations.
117+
include(GNUInstallDirs)
118+
119+
# Export the CMake targets to make it easy to create configuration files.
120+
install(
121+
EXPORT google_cloud_cpp_container-targets
122+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_container"
123+
COMPONENT google_cloud_cpp_development)
124+
125+
# Install the libraries and headers in the locations determined by
126+
# GNUInstallDirs
127+
install(
128+
TARGETS google_cloud_cpp_container google_cloud_cpp_container_protos
129+
EXPORT google_cloud_cpp_container-targets
130+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
131+
COMPONENT google_cloud_cpp_runtime
132+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
133+
COMPONENT google_cloud_cpp_runtime
134+
NAMELINK_SKIP
135+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
136+
COMPONENT google_cloud_cpp_development)
137+
# With CMake-3.12 and higher we could avoid this separate command (and the
138+
# duplication).
139+
install(
140+
TARGETS google_cloud_cpp_container google_cloud_cpp_container_protos
141+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
142+
COMPONENT google_cloud_cpp_development
143+
NAMELINK_ONLY
144+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
145+
COMPONENT google_cloud_cpp_development)
146+
147+
google_cloud_cpp_install_proto_library_protos(
148+
"google_cloud_cpp_container_protos" "${EXTERNAL_GOOGLEAPIS_SOURCE}")
149+
google_cloud_cpp_install_proto_library_headers(
150+
"google_cloud_cpp_container_protos")
151+
google_cloud_cpp_install_headers("google_cloud_cpp_container"
152+
"include/google/cloud/container")
153+
google_cloud_cpp_install_headers("google_cloud_cpp_container_mocks"
154+
"include/google/cloud/container")
155+
156+
# Setup global variables used in the following *.in files.
157+
set(GOOGLE_CLOUD_CONFIG_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
158+
set(GOOGLE_CLOUD_CONFIG_VERSION_MINOR ${PROJECT_VERSION_MINOR})
159+
set(GOOGLE_CLOUD_CONFIG_VERSION_PATCH ${PROJECT_VERSION_PATCH})
160+
set(GOOGLE_CLOUD_PC_NAME "The Kubernetes Engine API C++ Client Library")
161+
set(GOOGLE_CLOUD_PC_DESCRIPTION
162+
"Provides C++ APIs to use the Kubernetes Engine API.")
163+
set(GOOGLE_CLOUD_PC_LIBS "-lgoogle_cloud_cpp_container")
164+
string(CONCAT GOOGLE_CLOUD_PC_REQUIRES "google_cloud_cpp_grpc_utils"
165+
" google_cloud_cpp_common" " google_cloud_cpp_container_protos")
166+
167+
# Create and install the pkg-config files.
168+
configure_file("${PROJECT_SOURCE_DIR}/google/cloud/container/config.pc.in"
169+
"google_cloud_cpp_container.pc" @ONLY)
170+
install(
171+
FILES "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_container.pc"
172+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
173+
COMPONENT google_cloud_cpp_development)
174+
175+
# Create and install the CMake configuration files.
176+
include(CMakePackageConfigHelpers)
177+
configure_file("config.cmake.in" "google_cloud_cpp_container-config.cmake"
178+
@ONLY)
179+
write_basic_package_version_file(
180+
"google_cloud_cpp_container-config-version.cmake"
181+
VERSION ${PROJECT_VERSION}
182+
COMPATIBILITY ExactVersion)
183+
184+
install(
185+
FILES
186+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_container-config.cmake"
187+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_container-config-version.cmake"
188+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_container"
189+
COMPONENT google_cloud_cpp_development)
190+
191+
external_googleapis_install_pc("google_cloud_cpp_container_protos"
192+
"${PROJECT_SOURCE_DIR}/external/googleapis")

0 commit comments

Comments
 (0)