Skip to content

Commit 6a6d2ac

Browse files
authored
feat(serviceusage): generate library (#8040)
* feat(serviceusage): generate library * Run generators and format their outputs * Manually update READMEs, quickstart, and top-level stuff
1 parent 4be20c2 commit 6a6d2ac

Some content is hidden

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

41 files changed

+3234
-1
lines changed

BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,20 @@ cc_library(
539539
],
540540
)
541541

542+
cc_library(
543+
name = "experimental-serviceusage",
544+
deps = [
545+
"//google/cloud/serviceusage:google_cloud_cpp_serviceusage",
546+
],
547+
)
548+
549+
cc_library(
550+
name = "experimental-serviceusage_mocks",
551+
deps = [
552+
"//google/cloud/serviceusage:google_cloud_cpp_serviceusage_mocks",
553+
],
554+
)
555+
542556
cc_library(
543557
name = "experimental-shell",
544558
deps = [

ci/cloudbuild/builds/cmake-install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ mapfile -t actual_dirs < <(env -C "${INSTALL_PREFIX}" find -type d)
5353
# We maintain those here as a hard-coded list.
5454
mapfile -t expected_dirs < <(cat ci/etc/expected_install_directories)
5555
expected_dirs+=(
56-
./include/google/api
5756
# no RPC services in google/cloud/appengine/legacy
5857
./include/google/appengine/legacy
5958
# no RPC services in google/cloud/appengine/logging

ci/etc/expected_install_directories

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.
22
./include
33
./include/google
4+
./include/google/api
5+
./include/google/api/serviceusage
6+
./include/google/api/serviceusage/v1
47
./include/google/appengine
58
./include/google/appengine/v1
69
./include/google/bigtable
@@ -143,6 +146,9 @@
143146
./include/google/cloud/security
144147
./include/google/cloud/security/privateca
145148
./include/google/cloud/security/privateca/v1
149+
./include/google/cloud/serviceusage
150+
./include/google/cloud/serviceusage/internal
151+
./include/google/cloud/serviceusage/mocks
146152
./include/google/cloud/shell
147153
./include/google/cloud/shell/internal
148154
./include/google/cloud/shell/mocks
@@ -267,6 +273,7 @@
267273
./lib64/cmake/google_cloud_cpp_retail
268274
./lib64/cmake/google_cloud_cpp_scheduler
269275
./lib64/cmake/google_cloud_cpp_secretmanager
276+
./lib64/cmake/google_cloud_cpp_serviceusage
270277
./lib64/cmake/google_cloud_cpp_shell
271278
./lib64/cmake/google_cloud_cpp_storage
272279
./lib64/cmake/google_cloud_cpp_storagetransfer

ci/etc/full_feature_list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resourcemanager
3030
retail
3131
scheduler
3232
secretmanager
33+
serviceusage
3334
shell
3435
storage
3536
storagetransfer
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@com_google_googleapis//google/api:annotations_proto
2+
@com_google_googleapis//google/api:auth_proto
3+
@com_google_googleapis//google/api:client_proto
4+
@com_google_googleapis//google/api:documentation_proto
5+
@com_google_googleapis//google/api:endpoint_proto
6+
@com_google_googleapis//google/api:http_proto
7+
@com_google_googleapis//google/api:label_proto
8+
@com_google_googleapis//google/api:launch_stage_proto
9+
@com_google_googleapis//google/api:monitored_resource_proto
10+
@com_google_googleapis//google/api:monitoring_proto
11+
@com_google_googleapis//google/api:quota_proto
12+
@com_google_googleapis//google/api:usage_proto
13+
@com_google_googleapis//google/api:visibility_proto
14+
@com_google_googleapis//google/longrunning:operations_proto
15+
@com_google_googleapis//google/rpc:status_proto
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@com_google_googleapis//google/api/serviceusage/v1:resources.proto
2+
@com_google_googleapis//google/api/serviceusage/v1:serviceusage.proto

external/googleapis/update_libraries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ declare -A -r LIBRARIES=(
107107
"@com_google_googleapis//google/cloud/secretmanager/v1:secretmanager_cc_grpc" \
108108
"@com_google_googleapis//google/cloud/secretmanager/logging/v1:logging_cc_grpc"
109109
)"
110+
["serviceusage"]="@com_google_googleapis//google/api/serviceusage/v1:serviceusage_cc_grpc"
110111
["shell"]="@com_google_googleapis//google/cloud/shell/v1:shell_cc_grpc"
111112
["spanner"]="$(
112113
printf ",%s" \

generator/generator_config.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ service {
442442
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
443443
}
444444

445+
# Service Usage
446+
service {
447+
service_proto_path: "google/api/serviceusage/v1/serviceusage.proto"
448+
product_path: "google/cloud/serviceusage"
449+
initial_copyright_year: "2022"
450+
retryable_status_codes: ["kUnavailable"]
451+
}
452+
445453
# Shell
446454
service {
447455
service_proto_path: "google/cloud/shell/v1/cloudshell.proto"
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_serviceusage",
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/api/serviceusage/v1:serviceusage_cc_grpc",
42+
],
43+
)
44+
45+
cc_library(
46+
name = "google_cloud_cpp_serviceusage_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_serviceusage",
56+
"//google/cloud:google_cloud_cpp_common",
57+
"//google/cloud:google_cloud_cpp_grpc_utils",
58+
],
59+
)
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
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 "Service Usage API C++ Client")
19+
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Service Usage API")
20+
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
21+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "serviceusage_internal"
22+
"serviceusage_testing" "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::serviceusage_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_serviceusage_protos
44+
# cmake-format: sort
45+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/api/serviceusage/v1/resources.proto
46+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/api/serviceusage/v1/serviceusage.proto
47+
PROTO_PATH_DIRECTORIES
48+
"${EXTERNAL_GOOGLEAPIS_SOURCE}"
49+
"${PROTO_INCLUDE_DIR}")
50+
external_googleapis_set_version_and_alias(serviceusage_protos)
51+
target_link_libraries(
52+
google_cloud_cpp_serviceusage_protos
53+
PUBLIC #
54+
google-cloud-cpp::api_annotations_protos
55+
google-cloud-cpp::api_auth_protos
56+
google-cloud-cpp::api_client_protos
57+
google-cloud-cpp::api_documentation_protos
58+
google-cloud-cpp::api_endpoint_protos
59+
google-cloud-cpp::api_http_protos
60+
google-cloud-cpp::api_label_protos
61+
google-cloud-cpp::api_launch_stage_protos
62+
google-cloud-cpp::api_monitored_resource_protos
63+
google-cloud-cpp::api_monitoring_protos
64+
google-cloud-cpp::api_quota_protos
65+
google-cloud-cpp::api_usage_protos
66+
google-cloud-cpp::api_visibility_protos
67+
google-cloud-cpp::longrunning_operations_protos
68+
google-cloud-cpp::rpc_status_protos)
69+
70+
file(
71+
GLOB source_files
72+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
73+
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
74+
list(SORT source_files)
75+
add_library(google_cloud_cpp_serviceusage ${source_files})
76+
target_include_directories(
77+
google_cloud_cpp_serviceusage
78+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
79+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
80+
$<INSTALL_INTERFACE:include>)
81+
target_link_libraries(
82+
google_cloud_cpp_serviceusage
83+
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
84+
google-cloud-cpp::serviceusage_protos)
85+
google_cloud_cpp_add_common_options(google_cloud_cpp_serviceusage)
86+
set_target_properties(
87+
google_cloud_cpp_serviceusage
88+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-serviceusage
89+
VERSION "${PROJECT_VERSION}" SOVERSION
90+
"${PROJECT_VERSION_MAJOR}")
91+
target_compile_options(google_cloud_cpp_serviceusage
92+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
93+
94+
add_library(google-cloud-cpp::experimental-serviceusage ALIAS
95+
google_cloud_cpp_serviceusage)
96+
97+
# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
98+
# for these, a regular library would not work on macOS (where the library needs
99+
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
100+
# that they need absolute paths for their sources.
101+
file(
102+
GLOB relative_mock_files
103+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
104+
"mocks/*.h")
105+
list(SORT relative_mock_files)
106+
set(mock_files)
107+
foreach (file IN LISTS relative_mock_files)
108+
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
109+
endforeach ()
110+
add_library(google_cloud_cpp_serviceusage_mocks INTERFACE)
111+
target_sources(google_cloud_cpp_serviceusage_mocks INTERFACE ${mock_files})
112+
target_link_libraries(
113+
google_cloud_cpp_serviceusage_mocks
114+
INTERFACE google-cloud-cpp::experimental-serviceusage GTest::gmock_main
115+
GTest::gmock GTest::gtest)
116+
set_target_properties(
117+
google_cloud_cpp_serviceusage_mocks
118+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-serviceusage_mocks)
119+
target_include_directories(
120+
google_cloud_cpp_serviceusage_mocks
121+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
122+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
123+
$<INSTALL_INTERFACE:include>)
124+
target_compile_options(google_cloud_cpp_serviceusage_mocks
125+
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
126+
127+
# Get the destination directories based on the GNU recommendations.
128+
include(GNUInstallDirs)
129+
130+
# Export the CMake targets to make it easy to create configuration files.
131+
install(
132+
EXPORT google_cloud_cpp_serviceusage-targets
133+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_serviceusage"
134+
COMPONENT google_cloud_cpp_development)
135+
136+
# Install the libraries and headers in the locations determined by
137+
# GNUInstallDirs
138+
install(
139+
TARGETS google_cloud_cpp_serviceusage google_cloud_cpp_serviceusage_protos
140+
EXPORT google_cloud_cpp_serviceusage-targets
141+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
142+
COMPONENT google_cloud_cpp_runtime
143+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
144+
COMPONENT google_cloud_cpp_runtime
145+
NAMELINK_SKIP
146+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
147+
COMPONENT google_cloud_cpp_development)
148+
# With CMake-3.12 and higher we could avoid this separate command (and the
149+
# duplication).
150+
install(
151+
TARGETS google_cloud_cpp_serviceusage google_cloud_cpp_serviceusage_protos
152+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
153+
COMPONENT google_cloud_cpp_development
154+
NAMELINK_ONLY
155+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
156+
COMPONENT google_cloud_cpp_development)
157+
158+
google_cloud_cpp_install_proto_library_protos(
159+
"google_cloud_cpp_serviceusage_protos" "${EXTERNAL_GOOGLEAPIS_SOURCE}")
160+
google_cloud_cpp_install_proto_library_headers(
161+
"google_cloud_cpp_serviceusage_protos")
162+
google_cloud_cpp_install_headers("google_cloud_cpp_serviceusage"
163+
"include/google/cloud/serviceusage")
164+
google_cloud_cpp_install_headers("google_cloud_cpp_serviceusage_mocks"
165+
"include/google/cloud/serviceusage")
166+
167+
# Setup global variables used in the following *.in files.
168+
set(GOOGLE_CLOUD_CONFIG_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
169+
set(GOOGLE_CLOUD_CONFIG_VERSION_MINOR ${PROJECT_VERSION_MINOR})
170+
set(GOOGLE_CLOUD_CONFIG_VERSION_PATCH ${PROJECT_VERSION_PATCH})
171+
set(GOOGLE_CLOUD_PC_NAME "The Service Usage API C++ Client Library")
172+
set(GOOGLE_CLOUD_PC_DESCRIPTION
173+
"Provides C++ APIs to use the Service Usage API.")
174+
set(GOOGLE_CLOUD_PC_LIBS "-lgoogle_cloud_cpp_serviceusage")
175+
string(CONCAT GOOGLE_CLOUD_PC_REQUIRES "google_cloud_cpp_grpc_utils"
176+
" google_cloud_cpp_common"
177+
" google_cloud_cpp_serviceusage_protos")
178+
179+
# Create and install the pkg-config files.
180+
configure_file("${PROJECT_SOURCE_DIR}/google/cloud/serviceusage/config.pc.in"
181+
"google_cloud_cpp_serviceusage.pc" @ONLY)
182+
install(
183+
FILES "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_serviceusage.pc"
184+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
185+
COMPONENT google_cloud_cpp_development)
186+
187+
# Create and install the CMake configuration files.
188+
include(CMakePackageConfigHelpers)
189+
configure_file("config.cmake.in" "google_cloud_cpp_serviceusage-config.cmake"
190+
@ONLY)
191+
write_basic_package_version_file(
192+
"google_cloud_cpp_serviceusage-config-version.cmake"
193+
VERSION ${PROJECT_VERSION}
194+
COMPATIBILITY ExactVersion)
195+
196+
install(
197+
FILES
198+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_serviceusage-config.cmake"
199+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_serviceusage-config-version.cmake"
200+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_serviceusage"
201+
COMPONENT google_cloud_cpp_development)
202+
203+
external_googleapis_install_pc("google_cloud_cpp_serviceusage_protos"
204+
"${PROJECT_SOURCE_DIR}/external/googleapis")

0 commit comments

Comments
 (0)