Is it possible to simpifying google_cloud_cpp as a static library only to use 'AsyncStreamingRecognize() in speech/v1/speech_client.h only with google api key auth? #15794
Replies: 1 comment
-
|
I've succeeded to make BUILD.gn by assembling only related files to make gn build target. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is the following question from #15732.
chromium: Uses c++20 clang, protobuf 6.33.0.
I got an initial BUILD.gn to use AsyncStreamingRecognize() in speech/v1/speech_client.h with google gemini(claude.ai generated similar result), and I adjusted it to some extent to remove compiling errors,
but then it shows a lot of link errors like below.
I'm not familiar with cmake and bazel, so it seems that I need to learn about them while proceeding
migration google_cloud_cpp to chromium by writing BUILD.gn.
I'm only interested in using AsyncStreamingRecognize() in speech/v1/speech_client.h only with
google api key authentication(not with any other authentication method like service account, etc) to use
bidirection streaming recognition for chromium based browser,
I wonder if it would be possible to just migrate the related codes for this use case.
So I have questions below, and it would be very helpful if you could give some
answer even it is in rough form.
Do you think it would be possible to use
'AsyncStreamingRecognize() in speech/v1/speech_client.h only with google api key auth'
only by listing needed files in BUILD.gn,
or should some code modification to the related code files be needed?**
If I could skim all other logics regarding auth except google api key auth,
I could remove unnecessary files(which I don't need for my use case) and deps library the logic uses.
Except googleapis github proto files, would there be more files needed as dependency for this use case?
I'd like to avoid/or/minimize adding external dependencies as much as possible except ones already existing in chromium
as third_party libraries, because it would require making additional BUILD.gn for themselves,
and unlike cmake/bazel which can specify external dependency repos, chromium needs to pull
every dependency required and write BUILD.gn for each of them direcly. So I'd like to minimize/or/avoid it as much as possible.**
Do you have any rough idea which folder chain in google_cloud_cpp would be needed as dependency chain
so that the above api can be invoked?**
I'm sorry to ask a lot of questions at once.
I've been trying to make BUILD.gn to call AsyncStreamingRecognize() in speech/v1
during the last week, and reached the conclusion that
AI can't handle this kind of task and large projects like google_cloud_cpp and chromium,
so I need to do it myself again.
Any rough advice or guide would be very helpful for me to handle this migration task or
it would be nice if it is feasible task for my use case in the first place. Thank you for your help.
Copyright 2025 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
import("//build/config/features.gni")
import("//third_party/grpc/grpc_library.gni")
import("//third_party/protobuf/proto_library.gni")
------------------------------------------------------------------------------
1. Configuration & Generated Files
------------------------------------------------------------------------------
[CRITICAL] Generate build_info.cc
This provides the implementation for "google/cloud/internal/build_info.h".
It prevents linker errors when "user_agent_prefix.cc" is compiled.
write_file("$root_gen_dir/third_party/google_cloud_cpp/google/cloud/internal/build_info.cc",
[
"#include "google/cloud/internal/build_info.h"",
"#include "google/cloud/version.h"",
"namespace google { namespace cloud {",
"GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN",
"namespace internal {",
"std::string compiler() { return "clang"; }",
"std::string compiler_flags() { return ""; }",
"std::string build_metadata() { return "chromium-gn"; }",
"} // namespace internal",
"GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END",
"} } // namespace google::cloud",
])
config("google_cloud_cpp_config") {
include_dirs = [
".",
"$root_gen_dir/third_party/google_cloud_cpp",
"$root_gen_dir/third_party/googleapis",
"//third_party/google_cloud_cpp",
]
defines = []
cflags_cc = [
"-include", "ratio",
"-include", "chrono",
"-include", "cerrno",
]
}
config("googleapis_config") {
include_dirs = [ "//third_party/googleapis" ]
}
------------------------------------------------------------------------------
2. Proto Dependencies
------------------------------------------------------------------------------
2a. Google RPC Protos (Status, Error Details, Code)
Use proto_library (No gRPC services defined here)
proto_library("googleapis_rpc_protos") {
proto_in_dir = "//third_party/googleapis"
sources = [
"//third_party/googleapis/google/rpc/code.proto",
"//third_party/googleapis/google/rpc/error_details.proto",
"//third_party/googleapis/google/rpc/status.proto",
]
use_protobuf_full = true
}
2b. Google API Protos (Annotations, HTTP, Client)
Use proto_library (No gRPC services defined here)
proto_library("googleapis_api_protos") {
proto_in_dir = "//third_party/googleapis"
sources = [
"//third_party/googleapis/google/api/annotations.proto",
"//third_party/googleapis/google/api/client.proto",
"//third_party/googleapis/google/api/field_behavior.proto",
"//third_party/googleapis/google/api/http.proto",
"//third_party/googleapis/google/api/label.proto",
"//third_party/googleapis/google/api/launch_stage.proto",
"//third_party/googleapis/google/api/metric.proto",
"//third_party/googleapis/google/api/resource.proto",
"//third_party/googleapis/google/api/routing.proto",
]
proto_deps = [
":googleapis_rpc_protos",
]
use_protobuf_full = true
}
2c. Google LongRunning Protos (Operations)
Use grpc_library (Defines the 'Operations' service used for polling)
grpc_library("googleapis_longrunning_protos") {
proto_in_dir = "//third_party/googleapis"
sources = [
"//third_party/googleapis/google/longrunning/operations.proto",
]
proto_deps = [
":googleapis_api_protos",
":googleapis_rpc_protos",
]
use_protobuf_full = true
}
2d. Speech V1 Protos
Use grpc_library (Defines the 'Speech' service)
grpc_library("speech_protos") {
proto_in_dir = "//third_party/googleapis"
sources = [
"//third_party/googleapis/google/cloud/speech/v1/cloud_speech.proto",
"//third_party/googleapis/google/cloud/speech/v1/resource.proto",
]
proto_deps = [
":googleapis_api_protos",
":googleapis_longrunning_protos",
":googleapis_rpc_protos",
]
use_protobuf_full = true
extra_configs = [ ":googleapis_config" ]
}
2e. Google IAM Credentials Protos
grpc_library("iam_credentials_protos") {
proto_in_dir = "//third_party/googleapis"
sources = [
"//third_party/googleapis/google/iam/credentials/v1/common.proto",
"//third_party/googleapis/google/iam/credentials/v1/iamcredentials.proto",
]
proto_deps = [
":googleapis_api_protos",
":googleapis_rpc_protos",
]
use_protobuf_full = true
}
------------------------------------------------------------------------------
3. Common C++ Library (Core functionality)
------------------------------------------------------------------------------
source_set("google_cloud_cpp_common") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [
":googleapis_config",
":google_cloud_cpp_config"
]
sources = [
# Generated Implementation
"$root_gen_dir/third_party/google_cloud_cpp/google/cloud/internal/build_info.cc",
"google/cloud/internal/build_info.h",
]
public_deps = [
"//third_party/abseil-cpp:absl",
"//third_party/grpc:grpc++",
"//third_party/protobuf:protobuf_full",
"//third_party/boringssl",
":iam_credentials_protos",
":speech_protos",
]
}
------------------------------------------------------------------------------
4. Speech V1 C++ Library
------------------------------------------------------------------------------
source_set("speech_apis_v1") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":google_cloud_cpp_config"
]
sources = [
"google/cloud/speech/v1/internal/speech_auth_decorator.cc",
"google/cloud/speech/v1/internal/speech_auth_decorator.h",
"google/cloud/speech/v1/internal/speech_connection_impl.cc",
"google/cloud/speech/v1/internal/speech_connection_impl.h",
"google/cloud/speech/v1/internal/speech_logging_decorator.cc",
"google/cloud/speech/v1/internal/speech_logging_decorator.h",
"google/cloud/speech/v1/internal/speech_metadata_decorator.cc",
"google/cloud/speech/v1/internal/speech_metadata_decorator.h",
"google/cloud/speech/v1/internal/speech_option_defaults.cc",
"google/cloud/speech/v1/internal/speech_option_defaults.h",
"google/cloud/speech/v1/internal/speech_stub.cc",
"google/cloud/speech/v1/internal/speech_stub.h",
"google/cloud/speech/v1/internal/speech_stub_factory.cc",
"google/cloud/speech/v1/internal/speech_stub_factory.h",
"google/cloud/speech/v1/internal/speech_tracing_connection.cc",
"google/cloud/speech/v1/internal/speech_tracing_connection.h",
"google/cloud/speech/v1/internal/speech_tracing_stub.cc",
"google/cloud/speech/v1/internal/speech_tracing_stub.h",
"google/cloud/speech/v1/speech_client.cc",
"google/cloud/speech/v1/speech_client.h",
"google/cloud/speech/v1/speech_connection.cc",
"google/cloud/speech/v1/speech_connection.h",
"google/cloud/speech/v1/speech_connection_idempotency_policy.cc",
"google/cloud/speech/v1/speech_connection_idempotency_policy.h",
"google/cloud/speech/v1/speech_options.h",
]
public_deps = [
":google_cloud_cpp_common",
":speech_protos",
"//third_party/grpc:grpc++",
"//third_party/protobuf:protobuf_full",
]
}
FAILED: libcontent.so libcontent.so.TOC
"python3" "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Release+Asserts/bin/llvm-readelf" --nm="../../third_party/llvm-build/Release+Asserts/bin/llvm-nm" --sofile="./libcontent.so" --tocfile="./libcontent.so.TOC" --output="./libcontent.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libcontent.so" -Werror -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=fast -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,--icf=all -Wl,--color-diagnostics -Wl,--undefined-version -Wl,--no-call-graph-profile-sort --target=x86_64-unknown-linux-gnu -no-canonical-prefixes -Wl,--gc-sections -Wl,-z,defs -Wl,--as-needed -nostdlib++ --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -Wl,-rpath=$ORIGIN -Wl,-rpath=$ORIGIN -o "./libcontent.so" @"./libcontent.so.rsp"
ld.lld: error: undefined symbol: descriptor_table_google_2fapi_2fannotations_2eproto
ld.lld: error: undefined symbol: descriptor_table_google_2fapi_2fclient_2eproto
ld.lld: error: undefined symbol: descriptor_table_google_2fapi_2fresource_2eproto
ld.lld: error: undefined symbol: google::rpc::Status::~Status()
ld.lld: error: undefined symbol: google::rpc::Status::MergeImpl(google::protobuf::MessageLite&, google::protobuf::MessageLite const&)
ld.lld: error: undefined symbol: google::rpc::Status::Clear()
ld.lld: error: undefined symbol: google::rpc::Status::ByteSizeLong() const
ld.lld: error: undefined symbol: descriptor_table_google_2fapi_2ffield_5fbehavior_2eproto
ld.lld: error: undefined symbol: google::rpc::Status::Status(google::protobuf::Arena*, google::rpc::Status const&)
ld.lld: error: undefined symbol: descriptor_table_google_2flongrunning_2foperations_2eproto
ld.lld: error: undefined symbol: descriptor_table_google_2frpc_2fstatus_2eproto
ld.lld: error: undefined symbol: google::rpc::Status::table
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::HandCraftedLibClientHeader()
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::UrlEncode(std::__Cr::basic_string_view<char, std::__Cr::char_traits>)
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::GrpcAsyncAccessTokenCache::Create(google::cloud::v2_44::CompletionQueue, std::__Cr::function<google::cloud::v2_44::future<google::cloud::v2_44::StatusOrgoogle::cloud::v2_44::AccessToken> (google::cloud::v2_44::CompletionQueue&)>)
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::GrpcAsyncAccessTokenCache::GetAccessToken(std::__Cr::chrono::time_point<std::__Cr::chrono::system_clock, std::__Cr::chrono::duration<long long, std::__Cr::ratio<1l, 1000000l>>>)
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::GrpcAsyncAccessTokenCache::AsyncGetAccessToken(std::__Cr::chrono::time_point<std::__Cr::chrono::system_clock, std::__Cr::chrono::duration<long long, std::__Cr::ratio<1l, 1000000l>>>)
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::DebugString(google::protobuf::Message const&, google::cloud::v2_44::TracingOptions const&)
ld.lld: error: undefined symbol: google::cloud::v2_44::internal::DebugString(google::cloud::v2_44::Status const&, google::cloud::v2_44::TracingOptions const&)
ld.lld: error: undefined symbol: google::rpc::Status::Status(google::protobuf::Arena*)
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
Beta Was this translation helpful? Give feedback.
All reactions