Skip to content

Commit 98fb239

Browse files
authored
feat(speech): generate library (#8360)
1 parent f3edd81 commit 98fb239

41 files changed

Lines changed: 2851 additions & 2 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ EXPERIMENTAL_LIBRARIES = [
7777
"servicemanagement",
7878
"serviceusage",
7979
"shell",
80+
"speech",
8081
"storagetransfer",
8182
"talent",
8283
"texttospeech",

ci/cloudbuild/builds/cmake-install.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ expected_dirs+=(
9393
./include/google/cloud/spanner/admin/mocks
9494
./include/google/cloud/spanner/internal
9595
./include/google/cloud/spanner/mocks
96-
./include/google/cloud/speech
97-
./include/google/cloud/speech/v1
9896
./include/google/cloud/storage/oauth2
9997
./include/google/cloud/storage/testing
10098
# no gRPC services in google/cloud/workflows/type.

ci/etc/expected_install_directories

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
./include/google/cloud/spanner
264264
./include/google/cloud/spanner/admin
265265
./include/google/cloud/spanner/admin/internal
266+
./include/google/cloud/speech
267+
./include/google/cloud/speech/internal
268+
./include/google/cloud/speech/mocks
269+
./include/google/cloud/speech/v1
266270
./include/google/cloud/storage
267271
./include/google/cloud/storage/internal
268272
./include/google/cloud/storagetransfer
@@ -424,6 +428,7 @@
424428
./lib64/cmake/google_cloud_cpp_servicemanagement
425429
./lib64/cmake/google_cloud_cpp_serviceusage
426430
./lib64/cmake/google_cloud_cpp_shell
431+
./lib64/cmake/google_cloud_cpp_speech
427432
./lib64/cmake/google_cloud_cpp_storage
428433
./lib64/cmake/google_cloud_cpp_storagetransfer
429434
./lib64/cmake/google_cloud_cpp_talent

ci/etc/full_feature_list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ servicedirectory
5757
servicemanagement
5858
serviceusage
5959
shell
60+
speech
6061
storage
6162
storagetransfer
6263
talent

generator/generator_config.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,14 @@ service {
842842
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
843843
}
844844

845+
# Speech
846+
service {
847+
service_proto_path: "google/cloud/speech/v1/cloud_speech.proto"
848+
product_path: "google/cloud/speech"
849+
initial_copyright_year: "2022"
850+
retryable_status_codes: ["kUnavailable"]
851+
}
852+
845853
# Storage
846854
service {
847855
service_proto_path: "google/storage/v2/storage.proto"

google/cloud/speech/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_speech",
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/speech/v1:speech_cc_grpc",
42+
],
43+
)
44+
45+
cc_library(
46+
name = "google_cloud_cpp_speech_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_speech",
56+
"//google/cloud:google_cloud_cpp_common",
57+
"//google/cloud:google_cloud_cpp_grpc_utils",
58+
],
59+
)

google/cloud/speech/CMakeLists.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
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 "Cloud Speech-to-Text API C++ Client")
19+
set(DOXYGEN_PROJECT_BRIEF
20+
"A C++ Client Library for the Cloud Speech-to-Text API")
21+
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
22+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "speech_internal" "speech_testing"
23+
"examples")
24+
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
25+
26+
# Creates the proto headers needed by doxygen.
27+
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::speech_protos)
28+
29+
include(GoogleCloudCppCommon)
30+
31+
set(EXTERNAL_GOOGLEAPIS_SOURCE
32+
"${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
33+
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
34+
if (PROTO_INCLUDE_DIR)
35+
list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
36+
endif ()
37+
38+
include(CompileProtos)
39+
add_library(google_cloud_cpp_speech_protos INTERFACE)
40+
external_googleapis_set_version_and_alias(speech_protos)
41+
target_link_libraries(
42+
google_cloud_cpp_speech_protos
43+
INTERFACE #
44+
google-cloud-cpp::cloud_speech_protos
45+
google-cloud-cpp::api_annotations_protos
46+
google-cloud-cpp::api_client_protos
47+
google-cloud-cpp::api_field_behavior_protos
48+
google-cloud-cpp::api_http_protos
49+
google-cloud-cpp::api_resource_protos
50+
google-cloud-cpp::longrunning_operations_protos
51+
google-cloud-cpp::rpc_status_protos)
52+
53+
file(
54+
GLOB source_files
55+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
56+
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
57+
list(SORT source_files)
58+
add_library(google_cloud_cpp_speech ${source_files})
59+
target_include_directories(
60+
google_cloud_cpp_speech
61+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
62+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
63+
$<INSTALL_INTERFACE:include>)
64+
target_link_libraries(
65+
google_cloud_cpp_speech
66+
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
67+
google-cloud-cpp::speech_protos)
68+
google_cloud_cpp_add_common_options(google_cloud_cpp_speech)
69+
set_target_properties(
70+
google_cloud_cpp_speech
71+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-speech
72+
VERSION "${PROJECT_VERSION}" SOVERSION
73+
"${PROJECT_VERSION_MAJOR}")
74+
target_compile_options(google_cloud_cpp_speech
75+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
76+
77+
add_library(google-cloud-cpp::experimental-speech ALIAS google_cloud_cpp_speech)
78+
79+
# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
80+
# for these, a regular library would not work on macOS (where the library needs
81+
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
82+
# that they need absolute paths for their sources.
83+
file(
84+
GLOB relative_mock_files
85+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
86+
"mocks/*.h")
87+
list(SORT relative_mock_files)
88+
set(mock_files)
89+
foreach (file IN LISTS relative_mock_files)
90+
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
91+
endforeach ()
92+
add_library(google_cloud_cpp_speech_mocks INTERFACE)
93+
target_sources(google_cloud_cpp_speech_mocks INTERFACE ${mock_files})
94+
target_link_libraries(
95+
google_cloud_cpp_speech_mocks
96+
INTERFACE google-cloud-cpp::experimental-speech GTest::gmock_main
97+
GTest::gmock GTest::gtest)
98+
set_target_properties(
99+
google_cloud_cpp_speech_mocks
100+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-speech_mocks)
101+
target_include_directories(
102+
google_cloud_cpp_speech_mocks
103+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
104+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
105+
$<INSTALL_INTERFACE:include>)
106+
target_compile_options(google_cloud_cpp_speech_mocks
107+
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
108+
109+
include(CTest)
110+
if (BUILD_TESTING)
111+
add_executable(speech_quickstart "quickstart/quickstart.cc")
112+
target_link_libraries(speech_quickstart
113+
PRIVATE google-cloud-cpp::experimental-speech)
114+
google_cloud_cpp_add_common_options(speech_quickstart)
115+
add_test(
116+
NAME speech_quickstart
117+
COMMAND cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake"
118+
$<TARGET_FILE:speech_quickstart>)
119+
set_tests_properties(
120+
speech_quickstart
121+
PROPERTIES
122+
LABELS "integration-test;quickstart" ENVIRONMENT
123+
GOOGLE_CLOUD_CPP_USER_PROJECT=$ENV{GOOGLE_CLOUD_CPP_USER_PROJECT})
124+
endif ()
125+
126+
# Get the destination directories based on the GNU recommendations.
127+
include(GNUInstallDirs)
128+
129+
# Export the CMake targets to make it easy to create configuration files.
130+
install(
131+
EXPORT google_cloud_cpp_speech-targets
132+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_speech"
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_speech google_cloud_cpp_speech_protos
139+
EXPORT google_cloud_cpp_speech-targets
140+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
141+
COMPONENT google_cloud_cpp_runtime
142+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
143+
COMPONENT google_cloud_cpp_runtime
144+
NAMELINK_SKIP
145+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
146+
COMPONENT google_cloud_cpp_development)
147+
# With CMake-3.12 and higher we could avoid this separate command (and the
148+
# duplication).
149+
install(
150+
TARGETS google_cloud_cpp_speech google_cloud_cpp_speech_protos
151+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
152+
COMPONENT google_cloud_cpp_development
153+
NAMELINK_ONLY
154+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
155+
COMPONENT google_cloud_cpp_development)
156+
157+
google_cloud_cpp_install_proto_library_protos("google_cloud_cpp_speech_protos"
158+
"${EXTERNAL_GOOGLEAPIS_SOURCE}")
159+
google_cloud_cpp_install_proto_library_headers("google_cloud_cpp_speech_protos")
160+
google_cloud_cpp_install_headers("google_cloud_cpp_speech"
161+
"include/google/cloud/speech")
162+
google_cloud_cpp_install_headers("google_cloud_cpp_speech_mocks"
163+
"include/google/cloud/speech")
164+
165+
# Setup global variables used in the following *.in files.
166+
set(GOOGLE_CLOUD_CONFIG_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
167+
set(GOOGLE_CLOUD_CONFIG_VERSION_MINOR ${PROJECT_VERSION_MINOR})
168+
set(GOOGLE_CLOUD_CONFIG_VERSION_PATCH ${PROJECT_VERSION_PATCH})
169+
set(GOOGLE_CLOUD_PC_NAME "The Cloud Speech-to-Text API C++ Client Library")
170+
set(GOOGLE_CLOUD_PC_DESCRIPTION
171+
"Provides C++ APIs to use the Cloud Speech-to-Text API.")
172+
set(GOOGLE_CLOUD_PC_LIBS "-lgoogle_cloud_cpp_speech")
173+
string(CONCAT GOOGLE_CLOUD_PC_REQUIRES "google_cloud_cpp_grpc_utils"
174+
" google_cloud_cpp_common" " google_cloud_cpp_speech_protos")
175+
176+
# Create and install the pkg-config files.
177+
configure_file("${PROJECT_SOURCE_DIR}/google/cloud/speech/config.pc.in"
178+
"google_cloud_cpp_speech.pc" @ONLY)
179+
install(
180+
FILES "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_speech.pc"
181+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
182+
COMPONENT google_cloud_cpp_development)
183+
184+
# Create and install the CMake configuration files.
185+
include(CMakePackageConfigHelpers)
186+
configure_file("config.cmake.in" "google_cloud_cpp_speech-config.cmake" @ONLY)
187+
write_basic_package_version_file(
188+
"google_cloud_cpp_speech-config-version.cmake"
189+
VERSION ${PROJECT_VERSION}
190+
COMPATIBILITY ExactVersion)
191+
192+
install(
193+
FILES
194+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_speech-config.cmake"
195+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_speech-config-version.cmake"
196+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_speech"
197+
COMPONENT google_cloud_cpp_development)
198+
199+
external_googleapis_install_pc("google_cloud_cpp_speech_protos"
200+
"${PROJECT_SOURCE_DIR}/external/googleapis")

0 commit comments

Comments
 (0)