Skip to content

Commit 3595a78

Browse files
1 parent 3e052e0 commit 3595a78

File tree

4 files changed

+298
-1
lines changed

4 files changed

+298
-1
lines changed

modules/protobuf/31.1/MODULE.bazel

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
2+
# https://github.com/protocolbuffers/protobuf/issues/14313
3+
4+
module(
5+
name = "protobuf",
6+
version = "31.1", # Automatically updated on release
7+
compatibility_level = 1,
8+
repo_name = "com_google_protobuf",
9+
)
10+
11+
# LOWER BOUND dependency versions.
12+
# Bzlmod follows MVS:
13+
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
14+
# Thus the highest version in their module graph is resolved.
15+
16+
# These dependencies must be declared before the other rules dependencies.
17+
bazel_dep(name = "rules_apple", version = "3.16.0", repo_name = "build_bazel_rules_apple")
18+
bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support")
19+
20+
# Keep apple_support on 1.15.1 for now to avoid this issue:
21+
# https://github.com/bazelbuild/apple_support/issues/316
22+
single_version_override(
23+
module_name = "apple_support",
24+
version = "1.15.1",
25+
)
26+
27+
#ifndef PROTO2_OPENSOURCE
28+
# LINT.IfChange
29+
#endif // PROTO2_OPENSOURCE
30+
# protoc dependencies
31+
bazel_dep(name = "abseil-cpp", version = "20250127.0")
32+
bazel_dep(name = "rules_cc", version = "0.0.17")
33+
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
34+
#ifndef PROTO2_OPENSOURCE
35+
# LINT.ThenChange(//depot/google3/third_party/protobuf/compiler/notices.h)
36+
#endif // PROTO2_OPENSOURCE
37+
38+
# other dependencies
39+
bazel_dep(name = "bazel_features", version = "1.23.0", repo_name = "proto_bazel_features")
40+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
41+
bazel_dep(name = "jsoncpp", version = "1.9.6")
42+
bazel_dep(name = "rules_java", version = "8.6.1")
43+
bazel_dep(name = "rules_jvm_external", version = "6.7")
44+
bazel_dep(name = "rules_kotlin", version = "1.9.6")
45+
bazel_dep(name = "rules_license", version = "1.0.0")
46+
bazel_dep(name = "rules_pkg", version = "1.0.1")
47+
bazel_dep(name = "rules_python", version = "1.0.0")
48+
49+
bazel_dep(name = "rules_rust", version = "0.56.0", dev_dependency = True)
50+
bazel_dep(name = "rules_ruby", version = "0.17.3", dev_dependency = True)
51+
52+
# Workaround for https://github.com/bazelbuild/bazel-central-registry/issues/4230
53+
# rules_fuzzing 0.5.3 is not yet available in BCR.
54+
bazel_dep(name = "rules_fuzzing", version = "0.5.3", dev_dependency = True)
55+
archive_override(
56+
module_name = "rules_fuzzing",
57+
integrity = "sha256-CCdEIsQ4NBbfX5gpQ+QNWBQfdJwJAIu3gEQO7OaxE+Q=",
58+
strip_prefix = "rules_fuzzing-0.5.3",
59+
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.5.3.tar.gz"],
60+
)
61+
62+
# Workaround for https://github.com/bazel-contrib/rules_ruby/issues/216
63+
# Patch rules_ruby to disable automatic attempt to install bundler. When fixed,
64+
# delete Disable_bundle_install.patch and single_version_override() below.
65+
single_version_override(
66+
module_name = "rules_ruby",
67+
patch_strip = 1,
68+
patches = [
69+
"@com_google_protobuf//:Disable_bundle_install.patch",
70+
"@com_google_protobuf//:Neverlink_jruby_jars.patch",
71+
],
72+
version = "0.17.3",
73+
)
74+
75+
bazel_dep(name = "rules_shell", version = "0.2.0")
76+
bazel_dep(name = "platforms", version = "0.0.11")
77+
78+
# Ruby toolchains
79+
ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby", dev_dependency = True)
80+
ruby.toolchain(
81+
name = "ruby",
82+
version = "system",
83+
)
84+
use_repo(ruby, "ruby")
85+
ruby.bundle_fetch(
86+
name = "protobuf_bundle",
87+
gem_checksums = {
88+
"bigdecimal-3.1.9": "2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc",
89+
"bigdecimal-3.1.9-java": "dd9b8f7c870664cd9538a1325ce385ba57a6627969177258c4f0e661a7be4456",
90+
"ffi-1.17.1": "26f6b0dbd1101e6ffc09d3ca640b2a21840cc52731ad8a7ded9fb89e5fb0fc39",
91+
"ffi-1.17.1-java": "2546e11f9592e2b9b6de49eb96d2a378da47b0bb8469d5cbc9881a55c0d55da7",
92+
"ffi-compiler-1.3.2": "a94f3d81d12caf5c5d4ecf13980a70d0aeaa72268f3b9cc13358bcc6509184a0",
93+
"power_assert-2.0.5": "63b511b85bb8ea57336d25156864498644f5bbf028699ceda27949e0125bc323",
94+
"rake-13.2.1": "46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d",
95+
"rake-compiler-1.1.9": "51b5c95a1ff25cabaaf92e674a2bed847ab53d66302fc8843830df46ab1f51f5",
96+
"rake-compiler-dock-1.2.1": "3cc968d7ffc923c0e775b28d79a3389efb3d2b16ef52ed0298fbc97d347e5878",
97+
"test-unit-3.6.7": "c342bb9f7334ea84a361b43c20b063f405c0bf3c7dbe3ff38f61a91661d29221",
98+
},
99+
gemfile = "//ruby:Gemfile",
100+
gemfile_lock = "//ruby:Gemfile.lock",
101+
)
102+
use_repo(ruby, "protobuf_bundle", "ruby_toolchains")
103+
104+
register_toolchains(
105+
"@ruby_toolchains//:all",
106+
dev_dependency = True,
107+
)
108+
109+
# Proto toolchains
110+
register_toolchains("//bazel/private/toolchains:all")
111+
112+
SUPPORTED_PYTHON_VERSIONS = [
113+
"3.9",
114+
"3.10",
115+
"3.11",
116+
"3.12",
117+
]
118+
119+
# TODO: Support hermetic / system python in bzlmod.
120+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
121+
122+
[
123+
python.toolchain(
124+
# Disable root warning for .pyc cache misses since CI runs as root.
125+
# See https://github.com/bazelbuild/rules_python/pull/713
126+
ignore_root_user_error = True,
127+
is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1],
128+
python_version = python_version,
129+
)
130+
for python_version in SUPPORTED_PYTHON_VERSIONS
131+
]
132+
133+
use_repo(
134+
python,
135+
system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")),
136+
)
137+
138+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
139+
140+
[
141+
pip.parse(
142+
hub_name = "protobuf_pip_deps",
143+
python_version = python_version,
144+
requirements_lock = "//python:requirements.txt",
145+
)
146+
for python_version in SUPPORTED_PYTHON_VERSIONS
147+
]
148+
149+
use_repo(pip, "protobuf_pip_deps")
150+
151+
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate", dev_dependency = True)
152+
crate.spec(
153+
package = "googletest",
154+
version = ">0.0.0",
155+
)
156+
crate.spec(
157+
package = "paste",
158+
version = ">=1",
159+
)
160+
crate.spec(
161+
package = "quote",
162+
version = ">=1",
163+
)
164+
crate.spec(
165+
package = "syn",
166+
version = ">=2",
167+
)
168+
crate.from_specs()
169+
use_repo(crate, crate_index = "crates")
170+
171+
PROTOBUF_MAVEN_ARTIFACTS = [
172+
"com.google.code.findbugs:jsr305:3.0.2",
173+
"com.google.code.gson:gson:2.8.9",
174+
"com.google.errorprone:error_prone_annotations:2.5.1",
175+
"com.google.j2objc:j2objc-annotations:2.8",
176+
"com.google.guava:guava:32.0.1-jre",
177+
]
178+
179+
protobuf_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
180+
protobuf_maven.install(
181+
name = "protobuf_maven",
182+
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
183+
lock_file = "//:maven_install.json",
184+
repositories = [
185+
"https://repo1.maven.org/maven2",
186+
"https://repo.maven.apache.org/maven2",
187+
],
188+
)
189+
use_repo(protobuf_maven, "protobuf_maven")
190+
191+
# Temporarily pin transitive dependency for https://github.com/bazelbuild/bazel/issues/24426
192+
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
193+
194+
# Development dependencies
195+
protobuf_maven_dev = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)
196+
protobuf_maven_dev.install(
197+
name = "protobuf_maven_dev",
198+
artifacts = PROTOBUF_MAVEN_ARTIFACTS + [
199+
"com.google.caliper:caliper:1.0-beta-3",
200+
"com.google.guava:guava-testlib:32.0.1-jre",
201+
"com.google.testparameterinjector:test-parameter-injector:1.18",
202+
"com.google.truth:truth:1.1.2",
203+
"junit:junit:4.13.2",
204+
"org.mockito:mockito-core:4.3.1",
205+
"biz.aQute.bnd:biz.aQute.bndlib:6.4.0",
206+
"info.picocli:picocli:4.6.3",
207+
],
208+
lock_file = "//:maven_dev_install.json",
209+
repositories = [
210+
"https://repo1.maven.org/maven2",
211+
"https://repo.maven.apache.org/maven2",
212+
],
213+
)
214+
use_repo(protobuf_maven_dev, "protobuf_maven_dev")
215+
216+
bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True)
217+
bazel_dep(name = "rules_buf", version = "0.3.0", dev_dependency = True)
218+
bazel_dep(name = "rules_testing", version = "0.8.0", dev_dependency = True)
219+
bazel_dep(
220+
name = "abseil-py",
221+
version = "2.1.0",
222+
dev_dependency = True,
223+
repo_name = "com_google_absl_py",
224+
)
225+
226+
# For clang-cl configuration
227+
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
228+
use_repo(cc_configure, "local_config_cc")
229+
230+
# rules_proto are needed for @com_google_protobuf_v25 used in //compatibility/... tests
231+
bazel_dep(name = "rules_proto", version = "7.0.2", dev_dependency = True)
232+
233+
# For the Lua upb implementation
234+
bazel_dep(name = "lua", version = "5.4.6", dev_dependency = True)
235+
236+
# For benchmarks
237+
bazel_dep(name = "googleapis", version = "0.0.0-20240819-fe8ba054a", dev_dependency = True)
238+
bazel_dep(name = "google_benchmark", version = "1.9.2", dev_dependency = True)
239+
240+
# For testing runtime against old gencode from a previous major version.
241+
bazel_dep(name = "com_google_protobuf_v25", version = "25.0", dev_dependency = True)
242+
archive_override(
243+
module_name = "com_google_protobuf_v25",
244+
integrity = "sha256-e+7ZxRHWMs/3wirACU3Xcg5VAVMDnV2n4Fm8zrSIR0o=",
245+
patch_strip = 1,
246+
patches = [
247+
"@com_google_protobuf//:patches/protobuf_v25/0001-Add-MODULE.bazel.patch",
248+
"@com_google_protobuf//:patches/protobuf_v25/0002-Examples-MODULE.bazel.patch",
249+
"@com_google_protobuf//:patches/protobuf_v25/0003-relative-labels.patch",
250+
"@com_google_protobuf//:patches/protobuf_v25/0004-Add-utf8_range-dependency.patch",
251+
"@com_google_protobuf//:patches/protobuf_v25/0005-Make-rules_ruby-a-dev-only-dependency.patch",
252+
"@com_google_protobuf//:patches/protobuf_v25/0006-Add-repo_name.patch",
253+
"@com_google_protobuf//:patches/protobuf_v25/0007-Java-bazel8.patch",
254+
],
255+
strip_prefix = "protobuf-25.0",
256+
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v25.0/protobuf-25.0.tar.gz"],
257+
)
258+
259+
bazel_dep(name = "com_google_protobuf_previous_release", version = "29.0", dev_dependency = True)
260+
archive_override(
261+
module_name = "com_google_protobuf_previous_release",
262+
integrity = "sha256-EKDVjzmhqQnpXgDougtbHcZNApl/dBFRlTorNln254w=",
263+
patch_strip = 1,
264+
patches = [
265+
"@com_google_protobuf//:patches/protobuf_v29/0001-Update-module-name.patch",
266+
],
267+
strip_prefix = "protobuf-29.0",
268+
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v29.0/protobuf-29.0.tar.gz"],
269+
)

modules/protobuf/31.1/presubmit.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# LINT.IfChange(bcr_presubmit)
2+
bcr_test_module:
3+
module_path: examples
4+
matrix:
5+
platform: ["debian10", "macos", "macos_arm64", "ubuntu2004", "windows"]
6+
bazel: [7.x, 8.x]
7+
8+
tasks:
9+
verify_targets:
10+
name: "Verify build targets"
11+
platform: ${{ platform }}
12+
bazel: ${{ bazel }}
13+
build_targets:
14+
- '//...'
15+
- '@com_google_protobuf//:protobuf'
16+
- '@com_google_protobuf//:protobuf_lite'
17+
- '@com_google_protobuf//:protobuf_python'
18+
- '@com_google_protobuf//:protobuf_java'
19+
- '@com_google_protobuf//:protoc'
20+
- '@com_google_protobuf//:test_messages_proto2_cc_proto'
21+
- '@com_google_protobuf//:test_messages_proto3_cc_proto'
22+
# LINT.ThenChange(<ROOT_DIR>/.bazelci/presubmit.yml)

modules/protobuf/31.1/source.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "sha256-VU6EfkbHBb/ET7LQrlv3jzQ5X8v9hrp0czi1cO7yZ3E=",
3+
"strip_prefix": "protobuf-31.1",
4+
"url": "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protobuf-31.1.zip"
5+
}

modules/protobuf/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149
"30.2",
150150
"31.0-rc1",
151151
"31.0-rc2",
152-
"31.0"
152+
"31.0",
153+
"31.1"
153154
],
154155
"yanked_versions": {
155156
"3.19.0": "CVE-2022-3171 (https://github.com/advisories/GHSA-h4h5-3hr4-j3g2)",

0 commit comments

Comments
 (0)