Repository navigation
Expand file tree
/
Copy pathMODULE.bazel
More file actions
406 lines (351 loc) · 13.6 KB
/
Copy pathMODULE.bazel
File metadata and controls
406 lines (351 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/protocolbuffers/protobuf/issues/14313
module(
name = "protobuf",
version = "38.0-dev", # Automatically updated on release
bazel_compatibility = [">=8.0.0"],
compatibility_level = 1,
repo_name = "com_google_protobuf",
)
# 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 = "apple_support", version = "2.3.0", repo_name = "build_bazel_apple_support")
# Unused but must be pinned to avoid old broken versions
bazel_dep(name = "rules_proto", version = "7.1.0")
# protoc dependencies
bazel_dep(name = "abseil-cpp", version = "20250814.1")
bazel_dep(name = "rules_cc", version = "0.2.18")
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
# other dependencies
proto_bazel_features = use_repo_rule("//bazel/private/oss:proto_bazel_features.bzl", "proto_bazel_features")
proto_bazel_features(name = "proto_bazel_features")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "jsoncpp", version = "1.9.6.bcr.2")
bazel_dep(name = "rules_java", version = "8.6.1")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "rules_kotlin", version = "2.3.20")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_python", version = "2.3.4")
bazel_dep(name = "rules_rust", version = "0.69.0")
bazel_dep(name = "rules_ruby", version = "0.20.1", dev_dependency = True)
# Workaround for https://github.com/bazelbuild/bazel-central-registry/issues/4230
# rules_fuzzing 0.5.3 is not yet available in BCR.
bazel_dep(name = "rules_fuzzing", version = "0.5.3", dev_dependency = True)
archive_override(
module_name = "rules_fuzzing",
integrity = "sha256-CCdEIsQ4NBbfX5gpQ+QNWBQfdJwJAIu3gEQO7OaxE+Q=",
strip_prefix = "rules_fuzzing-0.5.3",
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.5.3.tar.gz"],
)
# Workaround for https://github.com/bazel-contrib/rules_ruby/issues/216
# Patch rules_ruby to disable automatic attempt to install bundler. When fixed,
# delete Disable_bundle_install.patch and single_version_override() below.
single_version_override(
module_name = "rules_ruby",
patch_strip = 1,
patches = [
"@com_google_protobuf//:Disable_bundle_install.patch",
],
)
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "platforms", version = "0.0.11")
# Ruby toolchains
ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby", dev_dependency = True)
ruby.toolchain(
name = "ruby",
version = "system",
)
use_repo(ruby, "ruby")
ruby.bundle_fetch(
name = "protobuf_bundle",
gem_checksums = {
"bigdecimal-3.1.9": "2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc",
"bigdecimal-3.1.9-java": "dd9b8f7c870664cd9538a1325ce385ba57a6627969177258c4f0e661a7be4456",
"ffi-1.17.1": "26f6b0dbd1101e6ffc09d3ca640b2a21840cc52731ad8a7ded9fb89e5fb0fc39",
"ffi-1.17.1-java": "2546e11f9592e2b9b6de49eb96d2a378da47b0bb8469d5cbc9881a55c0d55da7",
"ffi-compiler-1.3.2": "a94f3d81d12caf5c5d4ecf13980a70d0aeaa72268f3b9cc13358bcc6509184a0",
"power_assert-2.0.5": "63b511b85bb8ea57336d25156864498644f5bbf028699ceda27949e0125bc323",
"rake-13.2.1": "46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d",
"rake-compiler-1.1.9": "51b5c95a1ff25cabaaf92e674a2bed847ab53d66302fc8843830df46ab1f51f5",
"rake-compiler-dock-1.2.1": "3cc968d7ffc923c0e775b28d79a3389efb3d2b16ef52ed0298fbc97d347e5878",
"test-unit-3.6.7": "c342bb9f7334ea84a361b43c20b063f405c0bf3c7dbe3ff38f61a91661d29221",
},
gemfile = "//ruby:Gemfile",
gemfile_lock = "//ruby:Gemfile.lock",
)
use_repo(ruby, "protobuf_bundle", "ruby_toolchains")
register_toolchains(
"@ruby_toolchains//:all",
dev_dependency = True,
)
# Define toolchains that use pre-built protoc binaries.
prebuilt_protoc = use_extension("//bazel/private/oss/toolchains/prebuilt:protoc_extension.bzl", "protoc")
use_repo(
prebuilt_protoc,
"prebuilt_protoc.linux_aarch_64",
"prebuilt_protoc.linux_ppcle_64",
"prebuilt_protoc.linux_s390_64",
"prebuilt_protoc.linux_x86_32",
"prebuilt_protoc.linux_x86_64",
"prebuilt_protoc.osx_aarch_64",
"prebuilt_protoc.osx_x86_64",
"prebuilt_protoc.win32",
"prebuilt_protoc.win64",
)
# This registration applies when the config_setting for prefer_prebuilt_protoc is true.
# This is now enabled by default.
# It can be disabled using --@protobuf//bazel/flags:prefer_prebuilt_protoc=false
register_toolchains("//bazel/private/oss/toolchains/prebuilt:all")
# From-source protobuf toolchains
# Fallback if nothing is already registered
register_toolchains("//bazel/private/oss/toolchains:all")
SUPPORTED_PYTHON_VERSIONS = [
"3.11",
"3.12",
"3.13",
"3.14",
]
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
[
pip.parse(
hub_name = "protobuf_pip_deps",
python_version = python_version,
requirements_lock = "//python:requirements.txt",
target_platforms = [
"linux_x86_64",
"linux_aarch64",
"osx_aarch64",
"osx_x86_64",
"windows_x86_64",
],
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
use_repo(pip, "protobuf_pip_deps")
local_runtime_repo = use_repo_rule(
"@rules_python//python/local_toolchains:repos.bzl",
"local_runtime_repo",
)
local_runtime_toolchains_repo = use_repo_rule(
"@rules_python//python/local_toolchains:repos.bzl",
"local_runtime_toolchains_repo",
)
local_runtime_repo(
name = "local_python3",
dev_dependency = True,
interpreter_path = "python3",
on_failure = "fail",
)
local_runtime_toolchains_repo(
name = "local_toolchains",
dev_dependency = True,
runtimes = ["local_python3"],
target_settings = {
"local_python3": ["@//python:is_system_python"],
},
)
register_toolchains(
"@local_toolchains//:all",
dev_dependency = True,
)
# register python toolchains from rules_python for the versions we support.
# Used only by tests, doesn't affect downstream consumers of protobuf.
python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
[
python.toolchain(
is_default = (python_version == "3.11"),
python_version = python_version,
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust", dev_dependency = True)
# Minimum supported Rust version per the Foundational Rust Support Policy:
# https://github.com/google/oss-policies-info/blob/main/foundational-rust-support-matrix.md
rust.toolchain(
edition = "2024",
versions = ["1.92.0"],
)
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(
package = "googletest",
version = "0.14.2",
)
crate.spec(
package = "linkme",
version = "0.3.35",
)
crate.spec(
package = "paste",
version = "1.0.15",
)
crate.spec(
package = "quote",
version = "1.0.38",
)
crate.spec(
features = ["full"],
package = "syn",
version = ">=2, <3",
)
crate.from_specs(
cargo_lockfile = "//rust:Cargo.lock",
lockfile = "//rust:Cargo.Bazel.lock",
)
use_repo(crate, crate_index = "crates")
# Keep this list minimal; these dependencies will be part of the common `maven` install and could affect end-user projects.
PROTOBUF_MAVEN_ARTIFACTS = [
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.code.gson:gson:2.8.9",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.j2objc:j2objc-annotations:2.8",
"com.google.guava:guava:32.0.1-jre",
]
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
lock_file = "//:maven_install.json",
repositories = [
"https://repo1.maven.org/maven2",
"https://repo.maven.apache.org/maven2",
],
)
# Use the default "maven" namespace because protobuf java targets are exposed to users
# See https://github.com/protocolbuffers/protobuf/issues/21177
use_repo(maven, "maven")
# Temporarily pin transitive dependency for https://github.com/bazelbuild/bazel/issues/24426
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
# Development dependencies
protobuf_maven_dev = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)
protobuf_maven_dev.install(
name = "protobuf_maven_dev",
artifacts = PROTOBUF_MAVEN_ARTIFACTS + [
"com.google.caliper:caliper:1.0-beta-3",
"com.google.guava:guava-testlib:32.0.1-jre",
"com.google.testparameterinjector:test-parameter-injector:1.18",
"com.google.truth:truth:1.1.2",
"junit:junit:4.13.2",
"org.mockito:mockito-core:4.3.1",
"biz.aQute.bnd:biz.aQute.bndlib:6.4.0",
"info.picocli:picocli:4.6.3",
],
lock_file = "//:maven_dev_install.json",
repositories = [
"https://repo1.maven.org/maven2",
"https://repo.maven.apache.org/maven2",
],
)
use_repo(protobuf_maven_dev, "protobuf_maven_dev")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.9.0", dev_dependency = True)
bazel_dep(
name = "abseil-py",
version = "2.1.0",
dev_dependency = True,
repo_name = "com_google_absl_py",
)
# For clang-cl configuration
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")
# For the Lua upb implementation
bazel_dep(name = "lua", version = "5.4.6", dev_dependency = True)
# For benchmarks
bazel_dep(name = "googleapis", version = "0.0.0-20240819-fe8ba054a", dev_dependency = True)
bazel_dep(name = "google_benchmark", version = "1.9.2", dev_dependency = True)
# For testing runtime against old gencode from a previous major version.
bazel_dep(name = "com_google_protobuf_v25", version = "25.0", dev_dependency = True)
archive_override(
module_name = "com_google_protobuf_v25",
integrity = "sha256-e+7ZxRHWMs/3wirACU3Xcg5VAVMDnV2n4Fm8zrSIR0o=",
patch_strip = 1,
patches = [
"@com_google_protobuf//:patches/protobuf_v25/0001-Add-MODULE.bazel.patch",
"@com_google_protobuf//:patches/protobuf_v25/0002-Examples-MODULE.bazel.patch",
"@com_google_protobuf//:patches/protobuf_v25/0003-relative-labels.patch",
"@com_google_protobuf//:patches/protobuf_v25/0004-Add-utf8_range-dependency.patch",
"@com_google_protobuf//:patches/protobuf_v25/0005-Make-rules_ruby-a-dev-only-dependency.patch",
"@com_google_protobuf//:patches/protobuf_v25/0006-Add-repo_name.patch",
"@com_google_protobuf//:patches/protobuf_v25/0007-Java-bazel8.patch",
"@com_google_protobuf//:patches/protobuf_v25/0008-bazel9.patch",
],
strip_prefix = "protobuf-25.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v25.0/protobuf-25.0.tar.gz"],
)
# Register C++ toolchains for cross-compilation. These are used for compiling release binaries of
# protoc and the Python extension. They are disabled unless --//toolchain:release=true is passed.
register_toolchains(
"//toolchain:osx-x86_64-toolchain",
"//toolchain:osx-aarch_64-toolchain",
"//toolchain:linux-aarch_64-toolchain",
"//toolchain:linux-ppcle_64-toolchain",
"//toolchain:linux-s390_64-toolchain",
"//toolchain:linux-x86_32-toolchain",
"//toolchain:linux-x86_64-toolchain",
"//toolchain:win32-toolchain",
"//toolchain:win64-toolchain",
"//toolchain:k8-toolchain",
dev_dependency = True,
)
# Python headers for release
python_headers = use_extension("//python/dist:python_downloads.bzl", "python_headers", dev_dependency = True)
python_headers.source_archive(
sha256 = "64424e96e2457abbac899b90f9530985b51eef2905951febd935f0e73414caeb",
version = "3.11.0",
)
python_headers.nuget_package(
cpu = "i686",
sha256 = "c5ceeef9556d6aa85fac5d6567d35418a978e9b349f2c71818ddc03f14dd5a6d",
version = "3.11.0",
)
python_headers.nuget_package(
cpu = "x86-64",
sha256 = "e1236188a5841cfb9d14f7aac8b1fbdea10f82260d7f63610cc6260db76062a5",
version = "3.11.0",
)
use_repo(
python_headers,
"nuget_python_i686_3.11.0",
"nuget_python_x86-64_3.11.0",
"python-3.11.0",
)
bazel_dep(name = "jq.bzl", version = "0.6.1", dev_dependency = True)
jq = use_extension("@jq.bzl//jq:extensions.bzl", "toolchains", dev_dependency = True)
use_repo(jq, "jq_toolchains")
flag_alias(
name = "experimental_proto_descriptor_sets_include_source_info",
starlark_flag = "@//bazel/flags:experimental_proto_descriptor_sets_include_source_info",
)
flag_alias(
name = "experimental_protoc_opts",
starlark_flag = "@//bazel/flags:protocopt",
)
flag_alias(
name = "protocopt",
starlark_flag = "@//bazel/flags:protocopt",
)
flag_alias(
name = "proto_compiler",
starlark_flag = "@//bazel/flags:proto_compiler",
)
flag_alias(
name = "proto_toolchain_for_cc",
starlark_flag = "@//bazel/flags/cc:proto_toolchain_for_cc",
)
flag_alias(
name = "proto_toolchain_for_java",
starlark_flag = "@//bazel/flags/java:proto_toolchain_for_java",
)
flag_alias(
name = "proto_toolchain_for_javalite",
starlark_flag = "@//bazel/flags/java:proto_toolchain_for_javalite",
)
flag_alias(
name = "strict_public_imports",
starlark_flag = "@//bazel/flags:strict_public_imports",
)
flag_alias(
name = "cc_proto_library_header_suffixes",
starlark_flag = "@//bazel/flags/cc:cc_proto_library_header_suffixes",
)