@@ -12,6 +12,8 @@ load("//rs/experimental/toolchains:toolchain_utils.bzl", "sanitize_triple", "san
1212load ("//rs/private:cargo_repository.bzl" , "cargo_repository" )
1313load ("//rs/private:clippy_repository.bzl" , "clippy_repository" )
1414load ("//rs/private:host_tools_repository.bzl" , "host_tools_repository" )
15+ load ("//rs/private:rust_analyzer_repository.bzl" , "rust_analyzer_repository" )
16+ load ("//rs/private:rust_src_repository.bzl" , "rust_src_repository" )
1517load ("//rs/private:rustc_repository.bzl" , "rustc_repository" )
1618load ("//rs/private:rustfmt_repository.bzl" , "rustfmt_repository" )
1719load ("//rs/private:stdlib_repository.bzl" , "stdlib_repository" )
@@ -65,6 +67,10 @@ _TOOLCHAIN_TAG = tag_class(
6567 doc = "Rustfmt version (e.g. 1.86.0 or nightly/2025-04-03)" ,
6668 default = "" ,
6769 ),
70+ "rust_analyzer_version" : attr .string (
71+ doc = "Rust-analyzer version (e.g. 1.86.0 or nightly/2025-04-03)" ,
72+ default = "" ,
73+ ),
6874 "edition" : attr .string (
6975 doc = "Default edition to apply to toolchains." ,
7076 default = _DEFAULT_EDITION ,
@@ -106,17 +112,20 @@ def _toolchains_impl(mctx):
106112 name = _DEFAULT_TOOLCHAIN_REPO_NAME ,
107113 version = _DEFAULT_RUSTC_VERSION ,
108114 rustfmt_version = "" ,
115+ rust_analyzer_version = "" ,
109116 edition = _DEFAULT_EDITION ,
110117 extra_rustc_flags = {},
111118 extra_exec_rustc_flags = {},
112119 ))
113120
114121 versions = set ([])
115122 rustfmt_versions = set ([])
123+ rust_analyzer_versions = set ([])
116124
117125 for tag in version_tags :
118126 versions .add (tag .version )
119127 rustfmt_versions .add (tag .rustfmt_version or tag .version )
128+ rust_analyzer_versions .add (tag .rust_analyzer_version or tag .version )
120129
121130 existing_facts = getattr (mctx , "facts" , {}) or {}
122131 pending_downloads = {}
@@ -165,6 +174,17 @@ def _toolchains_impl(mctx):
165174 for tool_name in ["rustc" , "rustfmt" ]:
166175 _request_sha (tool_name , base_version , iso_date , exec_triple )
167176
177+ for version in rust_analyzer_versions :
178+ base_version , iso_date = _parse_version (version )
179+
180+ _request_sha ("rust-src" , base_version , iso_date , None )
181+
182+ for triple in SUPPORTED_EXEC_TRIPLES :
183+ exec_triple = _parse_triple (triple )
184+
185+ for tool_name in ["rustc" , "rust-analyzer" ]:
186+ _request_sha (tool_name , base_version , iso_date , exec_triple )
187+
168188 # Finish downloads and record facts.
169189 for archive_path , req in pending_downloads .items ():
170190 req .token .wait ()
@@ -182,7 +202,7 @@ def _toolchains_impl(mctx):
182202 host_arch = _normalize_arch_name (mctx .os .arch )
183203 host_cargo_repo = None
184204
185- for version in versions | rustfmt_versions :
205+ for version in versions | rustfmt_versions | rust_analyzer_versions :
186206 version_key = sanitize_version (version )
187207 base_version , iso_date = _parse_version (version )
188208
@@ -249,6 +269,29 @@ def _toolchains_impl(mctx):
249269 rustc_repo_build_file = "@rustc_{}_{}//:BUILD.bazel" .format (triple_suffix , version_key ),
250270 )
251271
272+ for version in rust_analyzer_versions :
273+ version_key = sanitize_version (version )
274+ base_version , iso_date = _parse_version (version )
275+
276+ rust_src_repository (
277+ name = "rust_src_{}" .format (version_key ),
278+ version = base_version ,
279+ iso_date = iso_date ,
280+ sha256 = _sha_for ("rust-src" , base_version , iso_date , None ),
281+ )
282+
283+ for triple in SUPPORTED_EXEC_TRIPLES :
284+ exec_triple = _parse_triple (triple )
285+ triple_suffix = exec_triple .system + "_" + exec_triple .arch
286+
287+ rust_analyzer_repository (
288+ name = "rust_analyzer_{}_{}" .format (triple_suffix , version_key ),
289+ triple = triple ,
290+ version = base_version ,
291+ iso_date = iso_date ,
292+ sha256 = _sha_for ("rust-analyzer" , base_version , iso_date , exec_triple ),
293+ )
294+
252295 host_tools_repository (
253296 name = "rs_rust_host_tools" ,
254297 host_cargo_repo = host_cargo_repo ,
@@ -264,10 +307,12 @@ def _toolchains_impl(mctx):
264307 for tag in version_tags :
265308 repo_name = tag .name
266309 rustfmt_version = tag .rustfmt_version or tag .version
310+ rust_analyzer_version = tag .rust_analyzer_version or tag .version
267311 existing = repo_configs .get (repo_name )
268312 if existing and (
269313 existing .version != tag .version or
270314 (existing .rustfmt_version or existing .version ) != rustfmt_version or
315+ (existing .rust_analyzer_version or existing .version ) != rust_analyzer_version or
271316 existing .edition != tag .edition or
272317 existing .extra_rustc_flags != tag .extra_rustc_flags or
273318 existing .extra_exec_rustc_flags != tag .extra_exec_rustc_flags
@@ -280,6 +325,7 @@ def _toolchains_impl(mctx):
280325 name = repo_name ,
281326 version = tag .version ,
282327 rustfmt_version = rustfmt_version ,
328+ rust_analyzer_version = rust_analyzer_version ,
283329 edition = tag .edition ,
284330 extra_rustc_flags = tag .extra_rustc_flags ,
285331 extra_exec_rustc_flags = tag .extra_exec_rustc_flags ,
0 commit comments