-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathMODULE.bazel
More file actions
926 lines (795 loc) · 35.4 KB
/
Copy pathMODULE.bazel
File metadata and controls
926 lines (795 loc) · 35.4 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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# 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")
multiversion_compat = use_extension("//bazel/resmoke/multiversion:version_compat.bzl", "multiversion_compat")
use_repo(multiversion_compat, "multiversion_compat_settings")
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")
mongo_tcmalloc_repository = use_repo_rule(
"//src/third_party/tcmalloc:repositories.bzl",
"mongo_tcmalloc_repository",
)
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,
)
# Downloads the llvm-bolt toolchain (arm64 or amd64) matching the host architecture.
setup_bolt_binaries = use_repo_rule("//bazel/repository_rules:bolt_binaries.bzl", "setup_bolt_binaries")
setup_bolt_binaries(name = "bolt_binaries")
# Downloads the perf tool (arm64 or amd64) matching the host architecture. perf is
# shipped separately from the llvm-bolt toolchain and is used by the bolt training pipeline.
setup_perf_binaries = use_repo_rule("//bazel/repository_rules:perf_binaries.bzl", "setup_perf_binaries")
setup_perf_binaries(name = "perf_binaries")
spidermonkey_wasi_repo = use_repo_rule(
"//src/mongo/scripting/mozjs/wasm:spidermonkey_wasi_repo.bzl",
"spidermonkey_wasi",
)
spidermonkey_wasi_repo(
name = "spidermonkey_wasi",
sha256 = "c4dac530b125bf9d09664a8d611db7e1775ab3b9f1b939b62a65c32a0362b289",
urls = [
"https://mdb-build-public.s3.amazonaws.com/spidermonkey-wasm/FIREFOX_140_12_0esr_RELEASE/spidermonkey-wasip2-release.tar.gz",
] * 5,
)
bazel_dep(name = "rules_cc", version = "0.2.10")
bazel_dep(name = "rules_fuzzing", version = "0.6.0")
bazel_dep(name = "rules_shell", version = "0.4.1")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "platforms", version = "0.0.11")
single_version_override(
module_name = "platforms",
version = "0.0.11",
)
bazel_dep(name = "rules_license", version = "1.0.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",
)
# rules_pycross reads uv.lock directly and generates Bazel-native targets
# (http_file for wheels, pycross_wheel_build for sdists). Pinned to 0.8.3,
# the last stable release before the v2.0 API rework. The hub is named
# `pypi` (see lock_import.import_uv() further down); callers reference deps
# as `@pypi//:<pkg>` via the shim in //bazel/uv:defs.bzl.
#
# Patches (all upstream-worthy):
# uv_translator_url_source: handle url-sourced `[tool.uv.sources]` entries
# whose sdist sub-entry has no url field, synthesizing a PEP 517-shaped
# file name for URLs (like GitHub /archive/<sha>.tar.gz) whose basename
# isn't one. Hashes come from uv.lock — no translation-time fetching.
# wheel_library_windows_dll_path: inject Python DLL dir onto action PATH so
# wheel_installer.exe's launcher can LoadLibrary python313.dll on Windows.
# installer_repo_extract + installer_tools_build: extract the `installer`
# wheel at repo-rule time and expose as a py_library instead of via
# zipimport (Windows runfiles staging bug).
# wheel_build_cargo_home: default CARGO_HOME into the WheelBuild action
# sandbox so Rust-backed sdist builds don't reach for an unwritable
# $HOME/.cargo (carried over from mongo's old rules_poetry patch; no
# current lock entry needs it — insurance for the first one that does).
# wheel_build_no_werror: strip -Werror from the toolchain flags forwarded
# into sdist builds — third-party build systems aren't held to mongo's
# warning policy (clang otherwise fatals on the harmless -L../lib that
# python-build-standalone's sysconfig adds to compile lines).
bazel_dep(name = "rules_pycross", version = "0.8.3")
single_version_override(
module_name = "rules_pycross",
patch_strip = 1,
patches = [
"//bazel/rules_pycross:uv_translator_url_source.patch",
"//bazel/rules_pycross:wheel_library_windows_dll_path.patch",
"//bazel/rules_pycross:installer_repo_extract.patch",
"//bazel/rules_pycross:installer_tools_build.patch",
"//bazel/rules_pycross:wheel_build_cargo_home.patch",
"//bazel/rules_pycross:wheel_build_no_werror.patch",
],
version = "0.8.3",
)
# Required by rules_pycross's wheel-install helpers.
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_pkg", version = "1.2.0")
single_version_override(
module_name = "rules_pkg",
patch_strip = 1,
patches = ["//bazel/rules_pkg:pkg_zip_windows_dll_path.patch"],
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",
)
mongo_tcmalloc_repository(name = "com_google_tcmalloc")
bazel_dep(
name = "google_benchmark",
version = "1.9.4",
dev_dependency = True,
repo_name = "com_github_google_benchmark",
)
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 = "2.2.0")
single_version_override(
module_name = "rules_python",
patch_strip = 1,
patches = [
# rules_python's ppc64le platform metadata uses legacy "ppc"
# identifiers, breaking two things: host-runtime detection (arch
# says "ppc", host detection says "ppc64le" -> no
# `python_<version>_host` repo -> rules_pycross's use_repo of it
# hard-fails module resolution) and the compatible_with constraint
# (cpu:ppc, while mongo's platforms declare cpu:ppc64le -> the
# pycross per-environment config_settings never match -> every
# @pypi wheel select() fails analysis on ppc64le). Upstream-worthy;
# see the patch header.
"//bazel/rules_python:host_platform_ppc64le.patch",
# Windows: under bootstrap_impl=script + venvs_use_declare_symlink=no,
# the stage-2 bootstrap recreates the venv at runtime by symlinking
# out of runfiles. Two host-dependent failure modes: paths beyond
# MAX_PATH (260) when LongPathsEnabled is off (WinError 87/3 —
# runfiles venv trees regularly exceed it), and outright symlink
# refusal without SeCreateSymbolicLinkPrivilege / Developer Mode
# (WinError 1314/87). Use \\?\ extended-length paths and fall
# back to copying, like CPython's venv module does. Upstream-worthy;
# see the patch header.
"//bazel/rules_python:bootstrap_windows_venv_robustness.patch",
# Windows: direct PyInfo import roots can contain wheel resources
# beyond MAX_PATH even when LongPathsEnabled is unset. Force those
# roots through the extended-length path form so importlib.resources
# can access nested package data. Upstream-worthy; see the patch
# header.
"//bazel/rules_python:site_init_windows_long_paths.patch",
],
version = "2.2.0",
)
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")
###################### NODE / NPM ######################
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
# Node.js runtime pinned to jstestfuzz's .nvmrc version. Only the root module
# may name a node toolchain. The extension always passes register = False, so
# this never competes with the default toolchain above; //bazel/resmoke selects
# the platform repos explicitly.
node.toolchain(
name = "nodejs16",
node_version = "16.18.1",
)
use_repo(
node,
"nodejs16_linux_amd64",
"nodejs16_linux_arm64",
)
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
###################### END NODE / NPM ######################
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")
# The hermetic C/C++ toolchain, plus the gdb build that is pinned against it.
setup_mongo_toolchains_extension = use_extension("//bazel:bzlmod.bzl", "setup_mongo_toolchains")
use_repo(
setup_mongo_toolchains_extension,
"gdb_v5",
"mongo_toolchain_v5",
)
register_toolchains("@mongo_toolchain_v5//:mongo_toolchain")
#
# Native/third-party system-compiler toolchain. Only matches the host platform
# when it is generated with USE_NATIVE_TOOLCHAIN=1 (which adds the
# use_native_toolchain constraint), so it never competes with the hermetic
# mongo toolchain on a normal build.
setup_mongo_native_toolchain = use_repo_rule("//bazel/toolchains/cc/mongo_native:native_toolchain.bzl", "setup_mongo_native_toolchain")
setup_mongo_native_toolchain(name = "mongo_native_toolchain")
register_toolchains("@mongo_native_toolchain//:mongo_native_toolchain")
# Shell formatter used by //bazel/format.
shfmt = use_repo_rule("//bazel/format:shfmt.bzl", "shfmt")
shfmt(name = "shfmt")
# GPG bundle used by //bazel/signing and the mongot extension signing key rules.
gpg_bundle_repo = use_repo_rule("//bazel/gpg:gpg.bzl", "gpg_bundle_repo")
gpg_bundle_repo(name = "gpg")
# db-contrib-tool, used to fetch multiversion server and mongot binaries.
db_contrib_tool = use_repo_rule("//bazel/db_contrib_tool:db_contrib_tool.bzl", "db_contrib_tool")
db_contrib_tool(name = "db_contrib_tool")
# RBE sysroot dump. Consumed by @mongo_toolchain_v5's generated BUILD file only
# when //bazel/config:use_rbe_sysroot_enabled is set.
sysroot_dump = use_repo_rule("//bazel/toolchains/cc/mongo_linux:sysroot_dump.bzl", "sysroot_dump")
sysroot_dump(name = "rbe_sysroot")
# Parallel compressors used by //bazel/install_rules when building archives.
setup_pigz = use_repo_rule("//bazel/install_rules:pigz.bzl", "setup_pigz")
setup_pigz(name = "pigz")
setup_zstd = use_repo_rule("//bazel/install_rules:zstd.bzl", "setup_zstd")
setup_zstd(name = "zstd")
# mongot extension public signing key, embedded into secure builds.
mongot_extension_signing_key_repo = use_repo_rule(
"//bazel/mongot_extension_signing_key:mongot_extension_signing_key.bzl",
"mongot_extension_signing_key_repo",
)
mongot_extension_signing_key_repo(name = "mongot_extension_signing_key")
coverity_toolchain = use_repo_rule("//bazel/coverity:coverity_toolchain.bzl", "coverity_toolchain")
coverity_toolchain(name = "rules_coverity")
# Prebuilt Windows Cyrus SASL. Not a bare http_archive because its generated
# BUILD file has to embed this repo's canonical directory in a /LIBPATH: flag;
# see the module docstring in windows_sasl.bzl.
windows_sasl = use_repo_rule("//bazel/install_rules:windows_sasl.bzl", "windows_sasl")
windows_sasl(name = "windows_sasl")
# Locates the host's MSVC install and VC redistributables. Windows-only; the
# generated BUILD file is empty elsewhere.
windows_msvc = use_repo_rule("//bazel/install_rules:windows_msvc.bzl", "windows_msvc")
windows_msvc(name = "local_windows_msvc")
# aspect_rules_lint is pulled in as a plain http_archive rather
# than as a bazel_dep: the module pulls in buf, which has no s390x build, and
# a bazel_dep would drag that into the graph on every platform.
http_archive(
name = "aspect_rules_lint",
sha256 = "f60e4a737a5e09402f5fa3bd182efa80dac5523ca4b9bc5c6fa8c06fbfb46630",
strip_prefix = "rules_lint-1.1.0",
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.1.0/rules_lint-v1.1.0.tar.gz",
)
http_file(
name = "windows_libclang",
downloaded_file_path = "libclang.dll",
sha256 = "fd77bdb8098cd82ab918bf50e9b12743e1fc8e524fa64cb90e729fbe9cee9c15",
urls = [
"https://mdb-build-public.s3.us-east-1.amazonaws.com/windows_libclang/libclang.dll",
] * 5,
)
http_archive(
name = "wix_toolset",
build_file_content = """
package(default_visibility = ["//visibility:public"])
filegroup(
name = "wix_binaries",
srcs = select({
"@platforms//os:windows": glob(["*"]),
"//conditions:default": [],
}),
)
filegroup(
name = "candle",
srcs = select({
"@platforms//os:windows": ["candle.exe"],
"//conditions:default": [],
}),
data = select({
"@platforms//os:windows": [":wix_binaries"],
"//conditions:default": [],
}),
)
filegroup(
name = "light",
srcs = select({
"@platforms//os:windows": ["light.exe"],
"//conditions:default": [],
}),
data = select({
"@platforms//os:windows": [":wix_binaries"],
"//conditions:default": [],
}),
)
""",
sha256 = "6ac824e1642d6f7277d0ed7ea09411a508f6116ba6fae0aa5f2c7daa2ff43d31",
urls = [
"https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip",
] * 5,
)
# This repository is normally created by db-contrib-tool or manually extracting
# the binaries at the proper location.
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
new_local_repository(
name = "mongot_localdev",
build_file_content = """
package(default_visibility = ["//visibility:public"])
filegroup(
name = "mongot_binaries",
srcs = glob(["**"], exclude = ["BUILD.bazel", "WORKSPACE", "MODULE.bazel", "MODULE.bazel.lock", "REPO.bazel"]),
)
""",
path = "mongot-localdev",
)
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_windows_cross_toolchains_extension = use_extension("//bazel/toolchains/cc/mongo_windows_cross:mongo_windows_cross_toolchain.bzl", "setup_mongo_windows_cross_toolchain_extension")
use_repo(setup_mongo_windows_cross_toolchains_extension, "mongo_windows_cross_toolchain", "mongo_windows_cross_toolchain_files")
register_toolchains(
"@mongo_windows_cross_toolchain//...",
)
setup_mongo_linux_cross_toolchains_extension = use_extension(
"//bazel/toolchains/cc/mongo_linux_cross:mongo_linux_cross_toolchain.bzl",
"setup_mongo_linux_cross_toolchains_extension",
)
use_repo(
setup_mongo_linux_cross_toolchains_extension,
"mongo_linux_cross_toolchain_v5_rhel8_ppc64le_on_rhel9_aarch64",
"mongo_linux_cross_toolchain_v5_rhel8_ppc64le_on_rhel9_x86_64",
"mongo_linux_cross_toolchain_v5_rhel8_s390x_on_rhel9_aarch64",
"mongo_linux_cross_toolchain_v5_rhel8_s390x_on_rhel9_x86_64",
"mongo_linux_cross_toolchain_v5_rhel9_ppc64le_on_rhel9_aarch64",
"mongo_linux_cross_toolchain_v5_rhel9_ppc64le_on_rhel9_x86_64",
"mongo_linux_cross_toolchain_v5_rhel9_s390x_on_rhel9_aarch64",
"mongo_linux_cross_toolchain_v5_rhel9_s390x_on_rhel9_x86_64",
)
register_toolchains(
"@mongo_linux_cross_toolchain_v5_rhel8_ppc64le_on_rhel9_aarch64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel8_ppc64le_on_rhel9_x86_64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel8_s390x_on_rhel9_aarch64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel8_s390x_on_rhel9_x86_64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel9_ppc64le_on_rhel9_aarch64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel9_ppc64le_on_rhel9_x86_64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel9_s390x_on_rhel9_aarch64//:mongo_toolchain",
"@mongo_linux_cross_toolchain_v5_rhel9_s390x_on_rhel9_x86_64//:mongo_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")
external_auth_aws_setup = use_repo_rule("//bazel/repository_rules:external_auth_aws_setup.bzl", "external_auth_aws_setup")
external_auth_aws_setup(name = "external_auth_aws_setup")
setup_libvoidstar = use_repo_rule("//bazel/repository_rules:libvoidstar.bzl", "setup_libvoidstar")
setup_libvoidstar(name = "libvoidstar")
setup_pgo_data = use_repo_rule("//bazel/repository_rules:pgo_data.bzl", "setup_pgo_data")
setup_pgo_data(name = "pgo_data")
setup_cspgo_data = use_repo_rule("//bazel/repository_rules:cspgo_data.bzl", "setup_cspgo_data")
setup_cspgo_data(name = "cspgo_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")
jstestfuzz_repository = use_extension(
"//bazel/repository_rules:jstestfuzz_repository.bzl",
"jstestfuzz_repository",
)
use_repo(jstestfuzz_repository, "jstestfuzz", "jstestfuzz_deterministic")
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 ######################
# Rules rust uses a custom cargo-bazel binary that doesnt exist for ppc so
# we have to build it ourselves. It needs to be in sync with the rules_rust
# version. Use the script buildscripts/build_cargo_bazel_ppc64le.sh on a ppc
# machine to regenerate the file, upload it to the public build s3 bucket
# and then fix the url in ppc64le_cargo_bazel_url.patch
bazel_dep(name = "rules_rust", version = "0.69.0")
# 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",
"//bazel/rules_rust:cargo_build_script_pwd_flags.patch",
],
version = "0.69.0",
)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
# The known_shas.bzl in rules_rust has a list of hashes for nightly tools
# Make sure this version is set to one of those, or specify the hashes yourself
rust.toolchain(
edition = "2024",
versions = ["nightly/2026-02-12"],
)
rust_host = use_extension("@rules_rust//rust:extensions.bzl", "rust_host_tools")
rust_host.host_tools(
name = "rust_host_tools_nightly",
edition = "2024",
version = "nightly/2026-02-12",
)
use_repo(rust_host, "rust_host_tools_nightly")
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(
package = "wasmtime",
version = "=44.0.1",
)
crate.spec(
features = [
"cranelift",
"component-model",
"async",
"wasi",
],
package = "wasmtime-c-api-impl",
version = "=44.0.1",
)
# 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",
patch_args = ["-p1"],
patches = [
"//bazel/wasmtime:store_rs.patch",
"//bazel/wasmtime:store_rs_resource_limiter.patch",
"//bazel/wasmtime:store_h.patch",
"//bazel/wasmtime:store_h_resource_limiter.patch",
"//bazel/wasmtime:store_hh.patch",
"//bazel/wasmtime:store_hh_resource_limiter.patch",
"//bazel/wasmtime:val_raw_u8_list_h.patch",
"//bazel/wasmtime:val_raw_u8_list_rs.patch",
"//bazel/wasmtime:config_wasm_backtrace_rs.patch",
"//bazel/wasmtime:config_wasm_backtrace_h.patch",
"//bazel/wasmtime:config_wasm_backtrace_hh.patch",
],
)
# The val_bytes_* patches add a Val::Bytes variant to the wasmtime component
# model, enabling a bulk-copy fast path when passing large BSON byte arrays
# (e.g. mapReduce documents) from C++ into WASM linear memory. Without this,
# each byte is boxed individually as a Val::U8, producing O(N) allocations for
# a single document. The patches must be applied to wasmtime, wasmtime-wast
# (the test harness), and wasmtime-wave (the value serialisation layer) so
# that all three agree on the Val enum layout.
# TODO (SERVER-127394): Contribute these patches upstream to the wasmtime repo
#
# signals_sigaltstack_ss_disable.patch (BF-44398/BF-44848, wasmtime#13857):
# Stack::drop munmaps the per-thread sigaltstack without SS_DISABLE, leaving a
# dangling kernel registration. ASan's thread teardown then unmaps whatever
# range is still registered, which by that point has been reused for live heap
# allocations — corrupting the address space of unrelated threads on *aubsan
# variants.
crate.annotation(
crate = "wasmtime",
patch_args = ["-p1"],
patches = [
"//bazel/wasmtime:val_bytes_fast_path.patch",
"//bazel/wasmtime:val_bytes_lift_fast_path.patch",
"//bazel/wasmtime:val_bytes_wave_fast_path.patch",
"//bazel/wasmtime:signals_sigaltstack_ss_disable.patch",
],
)
crate.annotation(
crate = "wasmtime-wast",
patch_args = ["-p1"],
patches = [
"//bazel/wasmtime:val_bytes_wast_fast_path.patch",
],
)
# 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",
"gc",
],
package = "wasmtime-cli",
version = "=44.0.1",
)
# 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.9+zstd.1.5.5",
)
# Disable zstd-sys's build script to prevent it from compiling its own copy of zstd.
# With LTO we can only have one set of zstd symbols, so we link against our vendored copy.
# The crate falls back to pre-generated bindings when the build script is disabled.
crate.annotation(
crate = "zstd-sys",
gen_build_script = "off",
deps = ["@@//src/third_party/zstandard:zstd"],
)
# Update the lock file using "CARGO_BAZEL_REPIN=1 bazel sync --only=crates"
# You may need to delete the contents of crates.lock first
crate.from_specs(
cargo_lockfile = "//bazel:crates.toml",
host_tools = "@rust_host_tools_nightly",
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")
# wit-bindgen-cli must live in a separate crate extension because
# artifact="bin" changes how crate_universe configures exec-platform
# toolchain resolution for the entire extension, which breaks Windows
# exec builds of other binary targets (e.g. wasmtime-cli). Any other artifact="bin"
# should live here.
cargo_bindeps = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
cargo_bindeps.spec(
artifact = "bin",
package = "wit-bindgen-cli",
version = "=0.51.0",
)
cargo_bindeps.annotation(
crate = "wit-bindgen-cli",
gen_all_binaries = True,
)
cargo_bindeps.from_specs(
name = "cargo_bindeps",
cargo_lockfile = "//bazel:cargo_bindeps.toml",
host_tools = "@rust_host_tools_nightly",
lockfile = "//bazel:cargo_bindeps.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(cargo_bindeps, "cargo_bindeps")
#################### 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",
)
###################### PYTHON DEPS (uv + rules_pycross) ######################
#
# rules_pycross consumes uv.lock directly and generates Bazel-native targets:
# every wheel is materialized via `http_file` (remote-cacheable), and any
# sdist that has to be built becomes a `pycross_wheel_build` action
# (remote-executable, sandbox-aware — unlike the WORKSPACE-phase `pip install`
# that rules_python's `whl_library` repository_rule performs).
#
# The @pypi hub name is chosen to match the label shape assumed by
# //bazel/uv:defs.bzl:dependency() — callers reference deps as @pypi//:<pkg>
# with PEP 503 normalized names (lowercase, `-` separators).
# rules_pycross's `environments.create_for_python_toolchains` extension
# consumes rules_python's `@python_versions` toolchain repo to enumerate
# per-platform PEP 425 tags and environment markers. We add a
# `python.toolchain()` call here PURELY for that metadata — we do NOT
# register these toolchains. Actual runtime Python selection stays with
# mongo's own custom python-build-standalone toolchains registered further
# up in this file (`@py_host`, `@py_linux_*`, `@py_macos_*`,
# `@py_windows_x86_64`), which take precedence via their explicit
# `register_toolchains(...)` calls.
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.13")
# `python.defaults()` (rules_python 2.x-only API) sets the default Python
# version at the root-module level and takes precedence over any
# `is_default = True` markings from transitive dependencies. Setting it
# to 3.13 forces both target and exec toolchain resolution to pick 3.13
# — critical for rules_pycross, whose per-wheel select() gates on
# `_env_python_3.13_*` config_settings and would otherwise fail under
# the exec config where transitive deps (grpc/protobuf/rules_pycross
# itself) push python_version to 3.12.
python.defaults(python_version = "3.13")
use_repo(python, "python_versions", "pythons_hub")
# Declare the (platform × python_version) matrix pycross should target.
# `create_for_python_toolchains` walks @python_versions to emit one
# `pycross_target_environment` JSON per (platform, version). rules_python's
# runtime manifest includes s390x/ppc64le entries for 3.13 (host detection
# on ppc64le additionally needs the host_platform_ppc64le.patch applied
# above), so this covers every platform mongo builds for.
environments = use_extension("@rules_pycross//pycross/extensions:environments.bzl", "environments")
environments.create_for_python_toolchains(
name = "mongo_pycross_environments",
platforms = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"ppc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
],
)
use_repo(environments, "mongo_pycross_environments")
lock_import = use_extension("@rules_pycross//pycross/extensions:lock_import.bzl", "lock_import")
lock_import.import_uv(
all_development_groups = True,
all_optional_groups = True,
# pycross builds sdists WITHOUT pip's build isolation, so PEP 517
# backends are not auto-provisioned. Nearly every sdist in this lock
# uses a setuptools-based backend (either `setuptools.build_meta`
# directly, the `:__legacy__` fallback for setup.py-only packages, or
# in-tree wrapper backends like pyyaml's `_pyyaml_pep517` and pyzstd's
# `pyzstd_pep517` that import setuptools at load time). Without this
# default, every such build fails with:
# BuildBackendException: Backend '<name>' is not available.
# setuptools and wheel are pinned in the `compile` dependency group.
default_build_dependencies = [
"setuptools",
"wheel",
],
lock_file = "//:uv.lock",
project_file = "//:pyproject.toml",
repo = "pypi",
# `uv lock --static-urls` is required by pycross so each locked package
# ships a concrete download URL rather than a URL template. See
# buildscripts/uv_sync.sh for the wrapper that enforces this.
require_static_urls = True,
target_environments = ["@mongo_pycross_environments//:environments"],
)
# `markdown-it-py` and `mdit-py-plugins` are mutually recursive: the former
# lists `mdit-py-plugins` as an optional extra dependency, the latter
# imports from `markdown-it-py`. Bazel refuses to configure a target graph
# with cycles, so break the edge on the markdown-it-py side (matches what
# the prior rules_poetry setup did via
# `poetry(excludes = ["mdit-py-plugins"])` in WORKSPACE.bazel). Callers
# that need mdit-py-plugins can still depend on it directly.
lock_import.package(
name = "markdown-it-py",
ignore_dependencies = ["mdit-py-plugins"],
repo = "pypi",
)
# The published ct3 wheels contain precompiled bytecode under
# Cheetah/Macros/__pycache__. Besides being non-portable, installer rejects
# wheel-provided __pycache__ contents as a security risk. Keep the upstream
# wheel usable while excluding only those generated files at install time.
lock_import.package(
name = "ct3",
install_exclude_globs = ["**/__pycache__/**"],
repo = "pypi",
)
lock_repos = use_extension("@rules_pycross//pycross/extensions:lock_repos.bzl", "lock_repos")
use_repo(lock_repos, "pypi")
###################### END PYTHON DEPS ######################
bazel_dep(name = "bazel_rules_mongo", version = "0.0.0")
local_path_override(
module_name = "bazel_rules_mongo",
path = "buildscripts/bazel_rules_mongo",
)
codeowners_validator_extension = use_extension("@bazel_rules_mongo//codeowners:codeowners_validator.bzl", "codeowners_validator_extension")
use_repo(codeowners_validator_extension, "codeowners_validator")
codeowners_binary_extension = use_extension("@bazel_rules_mongo//codeowners:codeowners_binary.bzl", "codeowners_binary_extension")
use_repo(codeowners_binary_extension, "codeowners_binary")