[bzlmod] Support repo @google_cloud_cpp in bzlmod (#41311)

This change should enable us to build most C/C++ tests with bzlmod.

`googleapis` is also updated because google_cloud_cpp 2.35.0 uses a modified version of googleapis. This requires us to copy some boilerplate code from upstream (BCR and google_cloud_cpp respectively).

Alternatively we could also use google_cloud_cpp from BCR, it takes less coding work but the lowest version available is 3.0.0 and requires a bunch of version bumps to other modules, so it might be more risky.

`rules_proto` version is increase to 7.1.0 (requested by google_cloud_cpp)

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #41311

PiperOrigin-RevId: 859764899
This commit is contained in:
yuanweiz
2026-01-22 14:03:50 -08:00
committed by Copybara-Service
parent abc7f59643
commit 8713acf3a6
5 changed files with 73 additions and 9 deletions

View File

@@ -28,7 +28,6 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "boringssl", version = "0.20241024.0") # mistmatched 20241211
bazel_dep(name = "c-ares", version = "1.19.1", repo_name = "com_github_cares_cares")
bazel_dep(name = "envoy_api", version = "0.0.0-20251216-6ef568c")
bazel_dep(name = "googleapis", version = "0.0.0-20251003-2193a2bf", repo_name = "com_google_googleapis")
bazel_dep(name = "googleapis-cc", version = "1.0.0")
bazel_dep(name = "googleapis-grpc-cc", version = "1.0.0")
bazel_dep(name = "googleapis-python", version = "1.0.0")
@@ -105,3 +104,25 @@ include("//bazel:com_google_fuzztest.MODULE.bazel")
# Provides repo @grpc_custom_exec_properties.
include("//bazel:grpc_custom_exec_properties.MODULE.bazel")
# -- google_cloud_cpp 2.35.0 related repos, which requires a modified version of googleapis, hence the version pinning.
bazel_dep(name = "googleapis", version = "0.0.0-20251003-2193a2bf", repo_name = "com_google_googleapis")
single_version_override(
module_name = "googleapis",
patch_strip = 1,
patches = [
"//bazel:googleapis/patches/fix_google_cloud_cpp.patch",
],
version = "0.0.0-20251003-2193a2bf",
)
bazel_dep(name = "google_cloud_cpp", version = "2.35.0", dev_dependency = True)
archive_override(
module_name = "google_cloud_cpp",
integrity = "sha256-geooz55bsDLTVrAYdAnzCxA1+OpbUwZ16iSMimwAcKo=",
strip_prefix = "google-cloud-cpp-2.35.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.35.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.35.0.tar.gz",
],
)

View File

@@ -0,0 +1,25 @@
# Inspired by https://github.com/googleapis/google-cloud-cpp/blob/2839e9dba793ca023e11ea67f201f66f74fa7d3e/bazel/googleapis.BUILD
diff --git a/BUILD.bazel b/BUILD.bazel
index 026553f5c..7c7bc0419 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,3 +1,19 @@
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"]) # Apache 2.0
+
+# This build file overlays on top of the BUILD files for the googleapis repo,
+# and it adds a target that lets us include their header files using
+# angle-brackets, thus treating their headers as system includes. This allows
+# us to dial-up the warnings in our own code, without seeing compiler warnings
+# from their headers, which we do not own.
+cc_library(
+ name = "googleapis_system_includes",
+ includes = [
+ ".",
+ ],
+)
+
genrule(
name = "build_gen",
srcs = glob(

View File

@@ -28,7 +28,6 @@ bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "boringssl", version = "0.20241024.0") # mistmatched 20241211
bazel_dep(name = "c-ares", version = "1.19.1", repo_name = "com_github_cares_cares")
bazel_dep(name = "envoy_api", version = "0.0.0-20251216-6ef568c")
bazel_dep(name = "googleapis", version = "0.0.0-20251003-2193a2bf", repo_name = "com_google_googleapis")
bazel_dep(name = "googleapis-cc", version = "1.0.0")
bazel_dep(name = "googleapis-grpc-cc", version = "1.0.0")
bazel_dep(name = "googleapis-python", version = "1.0.0")
@@ -105,3 +104,25 @@ include("//bazel:com_google_fuzztest.MODULE.bazel")
# Provides repo @grpc_custom_exec_properties.
include("//bazel:grpc_custom_exec_properties.MODULE.bazel")
# -- google_cloud_cpp 2.35.0 related repos, which requires a modified version of googleapis, hence the version pinning.
bazel_dep(name = "googleapis", version = "0.0.0-20251003-2193a2bf", repo_name = "com_google_googleapis")
single_version_override(
module_name = "googleapis",
patch_strip = 1,
patches = [
"//bazel:googleapis/patches/fix_google_cloud_cpp.patch",
],
version = "0.0.0-20251003-2193a2bf",
)
bazel_dep(name = "google_cloud_cpp", version = "2.35.0", dev_dependency = True)
archive_override(
module_name = "google_cloud_cpp",
integrity = "sha256-geooz55bsDLTVrAYdAnzCxA1+OpbUwZ16iSMimwAcKo=",
strip_prefix = "google-cloud-cpp-2.35.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.35.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.35.0.tar.gz",
],
)

View File

@@ -20,16 +20,14 @@ tools/bazel \
--bazelrc=tools/remote_build/linux_bzlmod.bazelrc \
build \
-- \
:all \
-:grpcpp_csm_observability # Needs google_cloud_cpp to be added to BCR
:all
# Test if examples are buildable without dev dependencies.
tools/bazel \
--bazelrc=tools/remote_build/linux_bzlmod.bazelrc \
build \
-- \
//examples/cpp/... \
-//examples/cpp/csm/... # Needs grpcpp_csm_observability
//examples/cpp/...
# Test if a few basic tests can pass.
# This is a temporary sanity check covering essential features,
@@ -64,5 +62,4 @@ tools/bazel \
build \
--define=//third_party:grpc_use_openssl=true \
-- \
:all \
-:grpcpp_csm_observability # Needs google_cloud_cpp to be added to BCR
:all

View File

@@ -22,6 +22,6 @@ common --enable_workspace=false
# TODO(weizheyuan): Re-enable this check once we upgrade all of the
# transitive dependencies that are currently at mismatched versions.
#common --check_direct_dependencies=error
common --ignore_dev_dependency
common --ignore_dev_dependency=false
build --jobs=200