-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathMODULE.bazel
More file actions
490 lines (420 loc) · 15.5 KB
/
MODULE.bazel
File metadata and controls
490 lines (420 loc) · 15.5 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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# Apple cc toolchain needs to be loaded before regular cc toolchain or else Apple will just use regular cc toolchain
bazel_dep(name = "apple_support", version = "1.24.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_features", version = "1.37.0")
bazel_features_deps = use_extension("//bazel:bzlmod.bzl", "bazel_features_deps")
use_repo(bazel_features_deps, "bazel_features_globals", "bazel_features_version")
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
http_archive(
name = "bazel_clang_tidy",
integrity = "sha256-PLwbo3dS1ZgeuSiaUctGRIU/O3ScB64+U2mEsN7fgtA=",
strip_prefix = "bazel_clang_tidy-1.7",
urls = [
# Implements retry by relisting each url multiple times to be used as a failover.
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
"https://github.com/mongodb-forks/bazel_clang_tidy/archive/refs/tags/v1.7.tar.gz",
] * 5,
)
# TODO(SERVER-107519): Get these binaries from an actual pipeline build and not locally produced binaries
http_archive(
name = "bolt_binaries",
build_file_content = """
package(default_visibility = ["//visibility:public"])
filegroup(
name = "merge-fdata",
srcs = ["bolt/bin/merge-fdata"],
)
filegroup(
name = "bolt",
srcs = ["bolt/bin/llvm-bolt"],
)
filegroup(
name = "perf2bolt",
srcs = ["bolt/bin/perf2bolt"],
)
filegroup(
name = "perf",
srcs = ["bolt/bin/perf"],
)
filegroup(
name = "libbolt_rt_instr",
srcs = ["bolt/lib/libbolt_rt_instr.a"],
)
""",
sha256 = "7de026eb0f82d1d113ce323d70cd35070b3d40cfea0c8f55c303c111a63feda3",
urls = [
"https://mdb-build-public.s3.us-east-1.amazonaws.com/andrew_pgo_scratch/bolt_perf_rseqbugfix2.tar.gz",
] * 5,
)
spidermonkey_wasi_repo = use_repo_rule(
"//src/mongo/scripting/mozjs/wasm:spidermonkey_wasi_repo.bzl",
"spidermonkey_wasi",
)
spidermonkey_wasi_repo(
name = "spidermonkey_wasi",
sha256 = "e89f9a9959555bb08444412600e6a4594125e15d68145f97c6d88e6395be1d6b",
urls = [
"https://mdb-build-public.s3.amazonaws.com/spidermonkey-wasm/FIREFOX_140_6_0esr_RELEASE/69d013e89378880007aaa010/spidermonkey-wasip2-release.tar.gz",
] * 5,
)
# SourceGraph indexer
http_file(
name = "scip-clang",
executable = True,
sha256 = "9fc7d1c309f8adee1b8663efa802efa7363ef22ee06f4711117535e406690689",
urls = [
# Implements retry by relisting each url multiple times to be used as a failover.
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
"https://github.com/sourcegraph/scip-clang/releases/download/v0.3.2/scip-clang-x86_64-linux",
] * 5,
)
# SourceGraph CLI
http_file(
name = "scip-src",
executable = True,
sha256 = "eb3d627c4dad56b9f5d06634b90384104db065d410c4b338fa5e6558be4f3ad9",
urls = [
# Implements retry by relisting each url multiple times to be used as a failover.
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
"https://github.com/sourcegraph/src-cli/releases/download/6.4.0/src_linux_amd64",
] * 5,
)
bazel_dep(name = "rules_cc", version = "0.2.10")
bazel_dep(name = "platforms", version = "0.0.11")
single_version_override(
module_name = "platforms",
version = "0.0.11",
)
# TODO SERVER-122884: move over from WORKSPACE
# buf does not support s390x
#bazel_dep(name = "aspect_rules_lint", version = "1.1.0")
#single_version_override(
# module_name = "aspect_rules_lint",
# version = "1.1.0",
#)
bazel_dep(name = "rules_multirun", version = "0.9.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.13.0")
single_version_override(
module_name = "aspect_bazel_lib",
version = "2.13.0",
)
bazel_dep(name = "aspect_rules_js", version = "2.1.3")
single_version_override(
module_name = "aspect_rules_js",
version = "2.1.3",
)
bazel_dep(name = "rules_nodejs", version = "6.3.0")
single_version_override(
module_name = "rules_nodejs",
version = "6.3.0",
)
bazel_dep(name = "rules_poetry", version = "")
git_override(
module_name = "rules_poetry",
commit = "092d43107d13e711ac4ac92050d8b570bcc8ef43",
patches = ["//bazel/rules_poetry:rules_poetry.patch"],
remote = "https://github.com/mongodb-forks/rules_poetry",
)
#
## We need skylib to be able to use config_setting_group in rule_poetry below
## https://github.com/bazelbuild/bazel-skylib/blob/main/docs/selects_doc.md#selectsconfig_setting_group
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_pkg", version = "1.2.0")
bazel_dep(name = "abseil-cpp", version = "20250512.1", repo_name = "com_google_absl")
local_path_override(
module_name = "abseil-cpp",
path = "src/third_party/abseil-cpp/dist",
)
bazel_dep(name = "protobuf", version = "31.1", repo_name = "com_google_protobuf")
local_path_override(
module_name = "protobuf",
path = "src/third_party/protobuf/dist",
)
bazel_dep(name = "googletest", version = "1.17.0", repo_name = "com_google_googletest")
local_path_override(
module_name = "googletest",
path = "src/third_party/googletest",
)
bazel_dep(name = "grpc", version = "1.74.1", repo_name = "com_github_grpc_grpc")
local_path_override(
module_name = "grpc",
path = "src/third_party/grpc/dist",
)
# googleapis still requests older grpc-java releases that import repos from
# grpc_repo_deps_ext. Keep grpc-java on a newer module that declares those
# dependencies directly so Bazel's module graph stays consistent with grpc@1.74.
single_version_override(
module_name = "grpc-java",
version = "1.74.0",
)
bazel_dep(name = "boringssl", version = "")
local_path_override(
module_name = "boringssl",
path = "src/third_party/boringssl_replacement",
)
bazel_dep(name = "c-ares", version = "1.27.0")
local_path_override(
module_name = "c-ares",
path = "src/third_party/cares",
)
bazel_dep(name = "re2", version = "2025-08-12")
local_path_override(
module_name = "re2",
path = "src/third_party/re2/dist",
)
bazel_dep(name = "zlib", version = "1.3.1")
local_path_override(
module_name = "zlib",
path = "src/third_party/zlib",
)
# When updating fuzztest run the following command
# bazel run @fuzztest//bazel:setup_configs > bazelrc.fuzztest
bazel_dep(name = "fuzztest", version = "20250805.0")
local_path_override(
module_name = "fuzztest",
path = "src/third_party/fuzztest/dist",
)
bazel_dep(name = "rules_python", version = "1.8.5")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
single_version_override(
module_name = "buildifier_prebuilt",
version = "6.4.0",
)
bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp")
local_path_override(
module_name = "prometheus-cpp",
path = "src/third_party/prometheus-cpp/dist",
)
bazel_dep(name = "rules_multitool", version = "0.4.0")
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
multitool.hub(lockfile = "//tools/lint:multitool.lock.json")
use_repo(multitool, "multitool")
# TODO SERVER-122885: port over from WORKSPACE
# currently breaks pyright
##node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
##node.toolchain(node_version = "18.20.4")
##
##npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
##npm.npm_translate_lock(
## name = "npm",
## npmrc = "//:.npmrc",
## pnpm_lock = "//:pnpm-lock.yaml",
## verify_node_modules_ignored = "//:.bazelignore",
##)
##use_repo(npm, "npm")
##
##pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
##use_repo(pnpm, "pnpm")
#
setup_local_config_platform = use_repo_rule("//bazel/platforms:local_config_platform.bzl", "setup_local_config_platform")
setup_local_config_platform(name = "internal_platforms_do_not_use")
register_execution_platforms("@internal_platforms_do_not_use//host:host")
# TODO SERVER-122886: port over from WORKSPACE
# cannot be moved without changing the path or creating a symlink
# to _main~setup_mongo_toolchains~mongo_toolchain_v4 and _main~setup_mongo_toolchains~mongo_toolchain_v5
##setup_mongo_toolchains_extension = use_extension("//bazel/toolchains:mongo_toolchain.bzl", "setup_mongo_toolchains_extension")
##use_repo(
## setup_mongo_toolchains_extension,
## "mongo_toolchain_v4",
## "mongo_toolchain_v5",
##)
#
setup_mongo_apple_toolchains_extension = use_extension("//bazel/toolchains/cc/mongo_apple:mongo_apple_toolchain.bzl", "setup_mongo_apple_toolchain_extension")
use_repo(setup_mongo_apple_toolchains_extension, "mongo_apple_toolchain")
register_toolchains(
"@mongo_apple_toolchain//...",
)
# Cross-compilation toolchain for building macOS binaries on Linux
setup_mongo_apple_cross_toolchains_extension = use_extension("//bazel/toolchains/cc/mongo_apple_cross:mongo_apple_cross_toolchain.bzl", "setup_mongo_apple_cross_toolchain_extension")
use_repo(setup_mongo_apple_cross_toolchains_extension, "mongo_apple_cross_toolchain", "mongo_apple_cross_toolchain_files")
register_toolchains(
"@mongo_apple_cross_toolchain//...",
)
setup_mongo_python_toolchains = use_extension("//bazel:bzlmod.bzl", "setup_mongo_python_toolchains")
use_repo(
setup_mongo_python_toolchains,
"py_host",
"py_linux_arm64",
"py_linux_ppc64le",
"py_linux_s390x",
"py_linux_x86_64",
"py_macos_arm64",
"py_macos_x86_64",
"py_windows_x86_64",
)
register_toolchains(
"@py_linux_arm64//:python_toolchain",
"@py_linux_ppc64le//:python_toolchain",
"@py_linux_s390x//:python_toolchain",
"@py_linux_x86_64//:python_toolchain",
"@py_macos_arm64//:python_toolchain",
"@py_macos_x86_64//:python_toolchain",
"@py_windows_x86_64//:python_toolchain",
)
# broken on windows currently
setup_local_host_values = use_repo_rule("//bazel/platforms:local_host_values.bzl", "setup_local_host_values")
setup_local_host_values(name = "local_host_values")
setup_evergreen_variables = use_repo_rule("//bazel/repository_rules:evergreen_variables.bzl", "setup_evergreen_variables")
setup_evergreen_variables(name = "evergreen_variables")
setup_pgo_data = use_repo_rule("//bazel/repository_rules:pgo_data.bzl", "setup_pgo_data")
setup_pgo_data(name = "pgo_data")
setup_bolt_data = use_repo_rule("//bazel/repository_rules:bolt_data.bzl", "setup_bolt_data")
setup_bolt_data(name = "bolt_data")
mothra_repository = use_repo_rule("//bazel/repository_rules:mothra.bzl", "mothra_repository")
# This repository is created in CI setup or by manually cloning the 10gen/mothra repo to ./mothra.
# If the directory doesn't exist, a stub with empty teams will be created.
mothra_repository(name = "mothra")
setup_mongo_windows_toolchains_extension = use_extension("//bazel/toolchains/cc/mongo_windows:mongo_toolchain.bzl", "setup_mongo_windows_toolchain_extension")
use_repo(setup_mongo_windows_toolchains_extension, "mongo_windows_toolchain")
register_toolchains("@mongo_windows_toolchain//...")
###################### RUST DEPS ######################
bazel_dep(name = "rules_rust", version = "0.68.1")
# Right now we dont build rust on ppc, when we do unsupported_host_skip_crates.patch
# should be removed
single_version_override(
module_name = "rules_rust",
patches = [
"//bazel/rules_rust:windows_long_path.patch",
"//bazel/rules_rust:ppc64le_platform.patch",
"//bazel/rules_rust:ppc64le_crates.patch",
"//bazel/rules_rust:ppc64le_cargo_bazel_url.patch",
],
version = "0.68.1",
)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2024",
versions = ["nightly/2025-12-11"],
)
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(
package = "wasmtime",
version = "=40.0.2",
)
crate.spec(
features = [
"cranelift",
"component-model",
"async",
"wasi",
],
package = "wasmtime-c-api-impl",
version = "=40.0.2",
)
# We partially custom build wasmtime_c because otherwise it tries to use cmake
# to create generate conf.h
crate.annotation(
additive_build_file = "//src/third_party/wasmtime:BUILD.bazel.wasmtime",
crate = "wasmtime-c-api-impl",
extra_aliased_targets = {"wasmtime_c": "wasmtime_c"},
gen_build_script = "off",
)
# Disable default features and re-enable everything except "objdump/explore" so we don't pull in capstone/capstone-sys.
# Can be renabled when it uses a version of capstone containing this commit - https://github.com/capstone-rust/capstone-rs/commit/28a6eb15fdc6fb988d13c663e8b4af4d7870d263
crate.spec(
default_features = False,
features = [
"run",
"compile",
"serve",
"wast",
"config",
"completion",
"wizer",
"wasi-nn",
"wasi-threads",
"wasi-http",
"wasi-config",
"wasi-keyvalue",
"wasi-tls",
"wat",
"parallel-compilation",
"pooling-allocator",
"cache",
"logging",
"demangle",
"cranelift",
"profiling",
"coredump",
"addr2line",
"debug-builtins",
"component-model",
"component-model-async",
"threads",
"stack-switching",
"winch",
"pulley",
],
package = "wasmtime-cli",
version = "=40.0.2",
)
# This causes us to build the actual binary and not just the rlib
crate.annotation(
crate = "wasmtime-cli",
gen_binaries = ["wasmtime"],
)
crate.spec(
package = "zstd-sys",
version = "=2.0.16+zstd.1.5.7",
)
# Bindgen uses libclang to parse code so it needs to know the path to libclang
crate.annotation_select(
build_script_data = [
"@@mongo_toolchain_v5//:libclang",
],
build_script_env = {
"LIBCLANG_PATH": "$(execpath @@mongo_toolchain_v5//:libclang)",
"BINDGEN_EXTRA_CLANG_ARGS": "-isystem$${pwd}/external/mongo_toolchain_v5/stow/llvm-v5/lib/clang/19/include",
},
crate = "zstd-sys",
repositories = ["crates"],
triples = [
"aarch64-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
],
)
crate.annotation_select(
build_script_data = [
"@@windows_libclang//file",
],
build_script_env = {
"LIBCLANG_PATH": "$(execpath @@windows_libclang//file)",
},
crate = "zstd-sys",
repositories = ["crates"],
triples = [
"x86_64-pc-windows-msvc",
],
)
# Update the lock file using "CARGO_BAZEL_REPIN=1 bazel sync --only=crates"
crate.from_specs(
cargo_lockfile = "//bazel:crates.toml",
lockfile = "//bazel:crates.lock",
supported_platform_triples = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
"powerpc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
],
)
use_repo(crate, "crates")
#################### END RUST DEPS ####################
wasi_deps = use_repo_rule(
"//bazel/toolchains/cc/mongo_wasm/toolchain:wasi_repo.bzl",
"setup_wasi_deps",
)
wasi_deps(name = "wasi_sdk")
spidermonkey_repo = use_repo_rule(
"//src/mongo/scripting/mozjs/wasm:spidermonkey_repo.bzl",
"spidermonkey_repository",
)
spidermonkey_repo(
name = "spidermonkey",
repository_file = "//src/mongo/scripting/mozjs/wasm/spider-monkey:spider-monkey-repository",
sha256_file = "//src/mongo/scripting/mozjs/wasm/spider-monkey:spider-monkey-sha256sum",
version_file = "//src/mongo/scripting/mozjs/wasm/spider-monkey:spider-monkey-version",
)