Skip to content

Commit e671bf5

Browse files
authored
feat(servicedirectory): generate library (#8065)
Fixes #8046.
1 parent 4448e09 commit e671bf5

File tree

61 files changed

+6246
-0
lines changed

Some content is hidden

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

61 files changed

+6246
-0
lines changed

BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,20 @@ cc_library(
553553
],
554554
)
555555

556+
cc_library(
557+
name = "experimental-servicedirectory",
558+
deps = [
559+
"//google/cloud/servicedirectory:google_cloud_cpp_servicedirectory",
560+
],
561+
)
562+
563+
cc_library(
564+
name = "experimental-servicedirectory_mocks",
565+
deps = [
566+
"//google/cloud/servicedirectory:google_cloud_cpp_servicedirectory_mocks",
567+
],
568+
)
569+
556570
cc_library(
557571
name = "experimental-serviceusage",
558572
deps = [

ci/etc/expected_install_directories

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150
./include/google/cloud/security
151151
./include/google/cloud/security/privateca
152152
./include/google/cloud/security/privateca/v1
153+
./include/google/cloud/servicedirectory
154+
./include/google/cloud/servicedirectory/internal
155+
./include/google/cloud/servicedirectory/mocks
156+
./include/google/cloud/servicedirectory/v1
153157
./include/google/cloud/serviceusage
154158
./include/google/cloud/serviceusage/internal
155159
./include/google/cloud/serviceusage/mocks
@@ -278,6 +282,7 @@
278282
./lib64/cmake/google_cloud_cpp_retail
279283
./lib64/cmake/google_cloud_cpp_scheduler
280284
./lib64/cmake/google_cloud_cpp_secretmanager
285+
./lib64/cmake/google_cloud_cpp_servicedirectory
281286
./lib64/cmake/google_cloud_cpp_serviceusage
282287
./lib64/cmake/google_cloud_cpp_shell
283288
./lib64/cmake/google_cloud_cpp_storage

ci/etc/full_feature_list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ resourcemanager
3131
retail
3232
scheduler
3333
secretmanager
34+
servicedirectory
3435
serviceusage
3536
shell
3637
storage
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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
5+
@com_google_googleapis//google/api:resource_proto
6+
@com_google_googleapis//google/iam/v1:iam_policy_proto
7+
@com_google_googleapis//google/iam/v1:options_proto
8+
@com_google_googleapis//google/iam/v1:policy_proto
9+
@com_google_googleapis//google/type:expr_proto
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@com_google_googleapis//google/cloud/servicedirectory/v1:endpoint.proto
2+
@com_google_googleapis//google/cloud/servicedirectory/v1:lookup_service.proto
3+
@com_google_googleapis//google/cloud/servicedirectory/v1:namespace.proto
4+
@com_google_googleapis//google/cloud/servicedirectory/v1:registration_service.proto
5+
@com_google_googleapis//google/cloud/servicedirectory/v1:service.proto

external/googleapis/update_libraries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ declare -A -r LIBRARIES=(
108108
"@com_google_googleapis//google/cloud/secretmanager/v1:secretmanager_cc_grpc" \
109109
"@com_google_googleapis//google/cloud/secretmanager/logging/v1:logging_cc_grpc"
110110
)"
111+
["servicedirectory"]="@com_google_googleapis//google/cloud/servicedirectory/v1:servicedirectory_cc_grpc"
111112
["serviceusage"]="@com_google_googleapis//google/api/serviceusage/v1:serviceusage_cc_grpc"
112113
["shell"]="@com_google_googleapis//google/cloud/shell/v1:shell_cc_grpc"
113114
["spanner"]="$(

generator/generator_config.textproto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,21 @@ service {
450450
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
451451
}
452452

453+
# Service Directory
454+
service {
455+
service_proto_path: "google/cloud/servicedirectory/v1/lookup_service.proto"
456+
product_path: "google/cloud/servicedirectory"
457+
initial_copyright_year: "2022"
458+
retryable_status_codes: ["kUnavailable", "kUnknown"]
459+
}
460+
461+
service {
462+
service_proto_path: "google/cloud/servicedirectory/v1/registration_service.proto"
463+
product_path: "google/cloud/servicedirectory"
464+
initial_copyright_year: "2022"
465+
retryable_status_codes: ["kUnavailable", "kUnknown"]
466+
}
467+
453468
# Service Usage
454469
service {
455470
service_proto_path: "google/api/serviceusage/v1/serviceusage.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_servicedirectory",
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/cloud/servicedirectory/v1:servicedirectory_cc_grpc",
42+
],
43+
)
44+
45+
cc_library(
46+
name = "google_cloud_cpp_servicedirectory_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_servicedirectory",
56+
"//google/cloud:google_cloud_cpp_common",
57+
"//google/cloud:google_cloud_cpp_grpc_utils",
58+
],
59+
)
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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 Directory API C++ Client")
19+
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Service Directory API")
20+
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
21+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "servicedirectory_internal"
22+
"servicedirectory_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::servicedirectory_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_servicedirectory_protos
44+
# cmake-format: sort
45+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/servicedirectory/v1/endpoint.proto
46+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/servicedirectory/v1/lookup_service.proto
47+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/servicedirectory/v1/namespace.proto
48+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/servicedirectory/v1/registration_service.proto
49+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/servicedirectory/v1/service.proto
50+
PROTO_PATH_DIRECTORIES
51+
"${EXTERNAL_GOOGLEAPIS_SOURCE}"
52+
"${PROTO_INCLUDE_DIR}")
53+
external_googleapis_set_version_and_alias(servicedirectory_protos)
54+
target_link_libraries(
55+
google_cloud_cpp_servicedirectory_protos
56+
PUBLIC #
57+
google-cloud-cpp::api_annotations_protos
58+
google-cloud-cpp::api_client_protos
59+
google-cloud-cpp::api_field_behavior_protos
60+
google-cloud-cpp::api_http_protos
61+
google-cloud-cpp::api_resource_protos
62+
google-cloud-cpp::iam_v1_iam_policy_protos
63+
google-cloud-cpp::iam_v1_options_protos
64+
google-cloud-cpp::iam_v1_policy_protos
65+
google-cloud-cpp::type_expr_protos)
66+
67+
file(
68+
GLOB source_files
69+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
70+
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
71+
list(SORT source_files)
72+
add_library(google_cloud_cpp_servicedirectory ${source_files})
73+
target_include_directories(
74+
google_cloud_cpp_servicedirectory
75+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
76+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
77+
$<INSTALL_INTERFACE:include>)
78+
target_link_libraries(
79+
google_cloud_cpp_servicedirectory
80+
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
81+
google-cloud-cpp::servicedirectory_protos)
82+
google_cloud_cpp_add_common_options(google_cloud_cpp_servicedirectory)
83+
set_target_properties(
84+
google_cloud_cpp_servicedirectory
85+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-servicedirectory
86+
VERSION "${PROJECT_VERSION}" SOVERSION
87+
"${PROJECT_VERSION_MAJOR}")
88+
target_compile_options(google_cloud_cpp_servicedirectory
89+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
90+
91+
add_library(google-cloud-cpp::experimental-servicedirectory ALIAS
92+
google_cloud_cpp_servicedirectory)
93+
94+
# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
95+
# for these, a regular library would not work on macOS (where the library needs
96+
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
97+
# that they need absolute paths for their sources.
98+
file(
99+
GLOB relative_mock_files
100+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
101+
"mocks/*.h")
102+
list(SORT relative_mock_files)
103+
set(mock_files)
104+
foreach (file IN LISTS relative_mock_files)
105+
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
106+
endforeach ()
107+
add_library(google_cloud_cpp_servicedirectory_mocks INTERFACE)
108+
target_sources(google_cloud_cpp_servicedirectory_mocks INTERFACE ${mock_files})
109+
target_link_libraries(
110+
google_cloud_cpp_servicedirectory_mocks
111+
INTERFACE google-cloud-cpp::experimental-servicedirectory GTest::gmock_main
112+
GTest::gmock GTest::gtest)
113+
set_target_properties(
114+
google_cloud_cpp_servicedirectory_mocks
115+
PROPERTIES EXPORT_NAME
116+
google-cloud-cpp::experimental-servicedirectory_mocks)
117+
target_include_directories(
118+
google_cloud_cpp_servicedirectory_mocks
119+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
120+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
121+
$<INSTALL_INTERFACE:include>)
122+
target_compile_options(google_cloud_cpp_servicedirectory_mocks
123+
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
124+
125+
# Get the destination directories based on the GNU recommendations.
126+
include(GNUInstallDirs)
127+
128+
# Export the CMake targets to make it easy to create configuration files.
129+
install(
130+
EXPORT google_cloud_cpp_servicedirectory-targets
131+
DESTINATION
132+
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_servicedirectory"
133+
COMPONENT google_cloud_cpp_development)
134+
135+
# Install the libraries and headers in the locations determined by
136+
# GNUInstallDirs
137+
install(
138+
TARGETS google_cloud_cpp_servicedirectory
139+
google_cloud_cpp_servicedirectory_protos
140+
EXPORT google_cloud_cpp_servicedirectory-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_servicedirectory
152+
google_cloud_cpp_servicedirectory_protos
153+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
154+
COMPONENT google_cloud_cpp_development
155+
NAMELINK_ONLY
156+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
157+
COMPONENT google_cloud_cpp_development)
158+
159+
google_cloud_cpp_install_proto_library_protos(
160+
"google_cloud_cpp_servicedirectory_protos" "${EXTERNAL_GOOGLEAPIS_SOURCE}")
161+
google_cloud_cpp_install_proto_library_headers(
162+
"google_cloud_cpp_servicedirectory_protos")
163+
google_cloud_cpp_install_headers("google_cloud_cpp_servicedirectory"
164+
"include/google/cloud/servicedirectory")
165+
google_cloud_cpp_install_headers("google_cloud_cpp_servicedirectory_mocks"
166+
"include/google/cloud/servicedirectory")
167+
168+
# Setup global variables used in the following *.in files.
169+
set(GOOGLE_CLOUD_CONFIG_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
170+
set(GOOGLE_CLOUD_CONFIG_VERSION_MINOR ${PROJECT_VERSION_MINOR})
171+
set(GOOGLE_CLOUD_CONFIG_VERSION_PATCH ${PROJECT_VERSION_PATCH})
172+
set(GOOGLE_CLOUD_PC_NAME "The Service Directory API C++ Client Library")
173+
set(GOOGLE_CLOUD_PC_DESCRIPTION
174+
"Provides C++ APIs to use the Service Directory API.")
175+
set(GOOGLE_CLOUD_PC_LIBS "-lgoogle_cloud_cpp_servicedirectory")
176+
string(CONCAT GOOGLE_CLOUD_PC_REQUIRES "google_cloud_cpp_grpc_utils"
177+
" google_cloud_cpp_common"
178+
" google_cloud_cpp_servicedirectory_protos")
179+
180+
# Create and install the pkg-config files.
181+
configure_file(
182+
"${PROJECT_SOURCE_DIR}/google/cloud/servicedirectory/config.pc.in"
183+
"google_cloud_cpp_servicedirectory.pc" @ONLY)
184+
install(
185+
FILES "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_servicedirectory.pc"
186+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
187+
COMPONENT google_cloud_cpp_development)
188+
189+
# Create and install the CMake configuration files.
190+
include(CMakePackageConfigHelpers)
191+
configure_file("config.cmake.in"
192+
"google_cloud_cpp_servicedirectory-config.cmake" @ONLY)
193+
write_basic_package_version_file(
194+
"google_cloud_cpp_servicedirectory-config-version.cmake"
195+
VERSION ${PROJECT_VERSION}
196+
COMPATIBILITY ExactVersion)
197+
198+
install(
199+
FILES
200+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_servicedirectory-config.cmake"
201+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_servicedirectory-config-version.cmake"
202+
DESTINATION
203+
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_servicedirectory"
204+
COMPONENT google_cloud_cpp_development)
205+
206+
external_googleapis_install_pc("google_cloud_cpp_servicedirectory_protos"
207+
"${PROJECT_SOURCE_DIR}/external/googleapis")

0 commit comments

Comments
 (0)