-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMODULE.bazel
More file actions
128 lines (117 loc) · 4.84 KB
/
MODULE.bazel
File metadata and controls
128 lines (117 loc) · 4.84 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
module(
name = "cross_platform",
version = "0.0.1",
)
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "platforms", version = "1.0.0")
# ── Python self-executable toolchain ─────────────────────────────────────────
# Downloads a hermetic CPython standalone build for the exec platform and
# registers it as //python:toolchain_type so py_self_executable can use it.
#
# To add pip packages:
# python_ext.pip(
# name = "pip_requests",
# url = "https://files.pythonhosted.org/packages/.../requests-2.32.3-py3-none-any.whl",
# sha256 = "70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6",
# )
# Then add the name to use_repo() and "@pip_requests//:pkg" to deps.
python_ext = use_extension("//python:python_extension.bzl", "python_ext")
python_ext.pip(
name = "pip_requests",
url = "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl",
sha256 = "70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6",
)
# requests transitive dependencies
python_ext.pip(
name = "pip_urllib3",
url = "https://files.pythonhosted.org/packages/ce/d9/5f4c13cecde62396b0d3fe530a50ccea91e7dfc1ccf0e09c228841bb5ba8/urllib3-2.2.3-py3-none-any.whl",
sha256 = "ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac",
)
python_ext.pip(
name = "pip_certifi",
url = "https://files.pythonhosted.org/packages/12/90/3c9ff0512038035f59d279fddeb79f5f1eccd8859f06d6163c58798b9487/certifi-2024.8.30-py3-none-any.whl",
sha256 = "922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8",
)
python_ext.pip(
name = "pip_charset_normalizer",
url = "https://files.pythonhosted.org/packages/bf/9b/08c0432272d77b04803958a4598a51e2a4b51c06640af8b8f0f908c18bf2/charset_normalizer-3.4.0-py3-none-any.whl",
sha256 = "fe9f97feb71aa9896b81973a7bbada8c49501dc73e58a10fcef6663af95e5079",
)
python_ext.pip(
name = "pip_idna",
url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl",
sha256 = "946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3",
)
use_repo(
python_ext,
"cpython",
"pip_requests",
"pip_urllib3",
"pip_certifi",
"pip_charset_normalizer",
"pip_idna",
)
register_toolchains("@cpython//:toolchain")
# ── C/C++ cross-compilation toolchain repos ───────────────────────────────────
# Java
bazel_dep(name = "rules_java", version = "9.6.1")
# Go
bazel_dep(name = "rules_go", version = "0.60.0")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.0")
# Python
bazel_dep(name = "rules_python", version = "2.0.1")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.12",
is_default = True,
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.12",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
# All external toolchain repos (GCC, LLVM, macOS SDK) are managed here
# so Bzlmod can see them via use_repo.
toolchain_ext = use_extension("//:toolchain_extension.bzl", "toolchain_ext")
use_repo(
toolchain_ext,
"gcc_9_x86_64",
"gcc_9_arm64",
"gcc_aarch64_native",
"llvm_macos_arm64",
"llvm_macos_x86_64",
"llvm_linux_x86_64",
"llvm_linux_aarch64",
"macos_sdk",
# Temurin JDK 21 — one per exec platform
"jdk_macos_arm64",
"jdk_macos_x86_64",
"jdk_linux_x86_64",
"jdk_linux_aarch64",
)
# macOS toolchains registered globally; Bazel auto-selects based on exec+target constraints.
# Linux toolchains are pinned per-build via --extra_toolchains in .bazelrc so they don't
# interfere with exec-platform resolution on non-Linux hosts.
register_toolchains(
# Temurin JDK 21 runtime toolchains — registered first (highest priority),
# preventing fallback to the failing local_jdk auto-detection.
"//:jdk_macos_arm64_toolchain",
"//:jdk_macos_x86_64_toolchain",
"//:jdk_linux_x86_64_toolchain",
"//:jdk_linux_aarch64_toolchain",
# macOS arm64 exec
"//:clang_macos_arm64_toolchain",
"//:clang_macos_x86_64_toolchain",
# macOS x86_64 exec
"//:clang_macos_x86_64_on_macos_x86_64_toolchain",
"//:clang_macos_arm64_on_macos_x86_64_toolchain",
# Linux x86_64 exec → macOS targets
"//:clang_macos_arm64_on_linux_x86_64_toolchain",
"//:clang_macos_x86_64_on_linux_x86_64_toolchain",
# Linux aarch64 exec → macOS targets
"//:clang_macos_arm64_on_linux_aarch64_toolchain",
"//:clang_macos_x86_64_on_linux_aarch64_toolchain",
)