dep-protobuf/patches/protobuf_v25/0001-Add-MODULE.bazel.patch
Adam Cozzette 2d72c4492b Remove protobuf v25 dep from WORKSPACE.bzlmod
We depend on protobuf v25 for the purpose of compatibility tests. Ideally we
would get v25 directly from BCR, but as far as I can tell there is no easy way
to get multiple versions of protobuf from BCR in the same bzlmod build. There
is
[multiple_version_override](https://bazel.build/rules/lib/globals/module#multiple_version_override),
but this seems to be geared toward resolving diamond dependency issues and not
so much toward deliberately testing against multiple versions.

This change therefore takes a different approach and uses
[archive_override](https://bazel.build/rules/lib/globals/module#archive_override).
I copied the necessary
[patches](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/protobuf/25.6/patches)
from BCR to get the code working with bzlmod. I also slightly tweaked the first
and last patches to give the module the name we want
(`com_google_protobuf_v25`).

I noticed that the v25 commit we depend on is not actually v25.0, but is v25.6
with a few additional fixes, so I updated our build to actually use v25.0.

PiperOrigin-RevId: 742781509
2025-04-01 11:47:10 -07:00

31 lines
1.2 KiB
Diff

diff --git a/MODULE.bazel b/MODULE.bazel
index 2d43e46df..f9c726c5a 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,2 +1,26 @@
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/protocolbuffers/protobuf/issues/14313
+
+module(
+ name = "com_google_protobuf_v25",
+ version = "25.0",
+ compatibility_level = 1,
+)
+
+# LOWER BOUND dependency versions.
+# Bzlmod follows MVS:
+# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
+# Thus the highest version in their module graph is resolved.
+bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
+bazel_dep(name = "bazel_skylib", version = "1.4.1")
+bazel_dep(name = "jsoncpp", version = "1.9.5")
+bazel_dep(name = "rules_cc", version = "0.0.9")
+bazel_dep(name = "rules_java", version = "4.0.0")
+bazel_dep(name = "rules_jvm_external", version = "5.1")
+bazel_dep(name = "rules_pkg", version = "0.7.0")
+bazel_dep(name = "rules_python", version = "0.10.2")
+bazel_dep(name = "platforms", version = "0.0.8")
+bazel_dep(name = "zlib", version = "1.2.11")
+
+# TODO: remove after toolchain types are moved to protobuf
+bazel_dep(name = "rules_proto", version = "4.0.0")