Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rust/private/repository_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,18 @@ rust_analyzer_toolchain(
name = "{name}",
proc_macro_srv = {proc_macro_srv},
rust_analyzer = {rust_analyzer},
rust_std = "//:rust_std-{target_triple}",
rustc = "{rustc}",
rustc_srcs = "//lib/rustlib/src:rustc_srcs",
cargo = "//:cargo",
visibility = ["//visibility:public"],
)
"""

def BUILD_for_rust_analyzer_toolchain(name, rustc, proc_macro_srv, rust_analyzer = None):
def BUILD_for_rust_analyzer_toolchain(name, target_triple, rustc, proc_macro_srv, rust_analyzer = None):
return _build_file_for_rust_analyzer_toolchain_template.format(
name = name,
target_triple = target_triple.str,
rustc = rustc,
proc_macro_srv = repr(proc_macro_srv),
rust_analyzer = repr(rust_analyzer) if rust_analyzer else "None",
Expand Down
10 changes: 10 additions & 0 deletions rust/private/rust_analyzer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ rust_analyzer_toolchain = rule(
executable = True,
allow_single_file = True,
),
"cargo": attr.label(
doc = "The path to a `cargo` binary.",
cfg = "exec",
executable = True,
allow_single_file = True,
),
"rustc": attr.label(
doc = "The path to a `rustc` binary.",
cfg = "exec",
Expand All @@ -350,6 +356,10 @@ rust_analyzer_toolchain = rule(
doc = "The direct path to rustc srcs relative to rustc_srcs package root.",
default = "library",
),
"rust_std": attr.label(
doc = "The core library of rust.",
mandatory = True,
),
},
)

Expand Down
19 changes: 19 additions & 0 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,24 @@ def _rust_analyzer_toolchain_tools_repository_impl(repository_ctx):
build_contents.append(BUILD_for_rust_analyzer_proc_macro_srv(host_triple))
proc_macro_srv = "//:rust_analyzer_proc_macro_srv"

rust_stdlib_content, rust_stdlib_sha256 = load_rust_stdlib(
ctx = repository_ctx,
target_triple = host_triple,
version = version,
iso_date = iso_date,
)
build_contents.append(rust_stdlib_content)
sha256s.update(rust_stdlib_sha256)

cargo_content, cargo_sha256 = load_cargo(
ctx = repository_ctx,
iso_date = iso_date,
target_triple = host_triple,
version = version,
)
build_contents.append(cargo_content)
sha256s.update(cargo_sha256)

# Load rust-analyzer binary from official Rust distribution
rust_analyzer = None
rust_analyzer_content, rust_analyzer_sha256 = load_rust_analyzer(
Expand All @@ -885,6 +903,7 @@ def _rust_analyzer_toolchain_tools_repository_impl(repository_ctx):

build_contents.append(BUILD_for_rust_analyzer_toolchain(
name = "rust_analyzer_toolchain",
target_triple = host_triple,
rustc = rustc,
proc_macro_srv = proc_macro_srv,
rust_analyzer = rust_analyzer,
Expand Down