Remove compiler_for from dist::RustAnalyzer

This commit is contained in:
Jakub Beránek 2025-08-15 19:43:43 +02:00
parent 648d6ce66f
commit fc4bf137a1
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 16 additions and 12 deletions

View file

@ -1334,9 +1334,10 @@ impl Step for Cargo {
}
}
/// Distribute the rust-analyzer component, which is used as a LSP by various IDEs.
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct RustAnalyzer {
pub build_compiler: Compiler,
pub compilers: RustcPrivateCompilers,
pub target: TargetSelection,
}
@ -1352,21 +1353,14 @@ impl Step for RustAnalyzer {
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustAnalyzer {
build_compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.host_target,
run.target,
),
compilers: RustcPrivateCompilers::new(run.builder, run.builder.top_stage, run.target),
target: run.target,
});
}
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
let target = self.target;
let compilers =
RustcPrivateCompilers::from_build_compiler(builder, self.build_compiler, self.target);
let rust_analyzer = builder.ensure(tool::RustAnalyzer::from_compilers(compilers));
let rust_analyzer = builder.ensure(tool::RustAnalyzer::from_compilers(self.compilers));
let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);
tarball.set_overlay(OverlayKind::RustAnalyzer);
@ -1375,6 +1369,13 @@ impl Step for RustAnalyzer {
tarball.add_legal_and_readme_to("share/doc/rust-analyzer");
Some(tarball.generate())
}
fn metadata(&self) -> Option<StepMetadata> {
Some(
StepMetadata::dist("rust-analyzer", self.target)
.built_by(self.compilers.build_compiler()),
)
}
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
@ -1672,7 +1673,7 @@ impl Step for Extended {
add_component!("rust-json-docs" => JsonDocs { build_compiler: target_compiler, target });
add_component!("cargo" => Cargo { build_compiler: compiler, target });
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });
add_component!("rust-analyzer" => RustAnalyzer { compilers: RustcPrivateCompilers::from_build_compiler(builder, compiler, target), target });
add_component!("llvm-components" => LlvmTools { target });
add_component!("clippy" => Clippy { build_compiler: compiler, target });
add_component!("miri" => Miri { build_compiler: compiler, target });

View file

@ -7,6 +7,7 @@ use std::path::{Component, Path, PathBuf};
use std::{env, fs};
use crate::core::build_steps::dist;
use crate::core::build_steps::tool::RustcPrivateCompilers;
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::core::config::{Config, TargetSelection};
use crate::utils::exec::command;
@ -227,7 +228,7 @@ install!((self, builder, _config),
};
RustAnalyzer, alias = "rust-analyzer", Self::should_build(_config), IS_HOST: true, {
if let Some(tarball) =
builder.ensure(dist::RustAnalyzer { build_compiler: self.compiler, target: self.target })
builder.ensure(dist::RustAnalyzer { compilers: RustcPrivateCompilers::from_build_compiler(builder, self.compiler, self.target), target: self.target })
{
install_sh(builder, "rust-analyzer", self.compiler.stage, Some(self.target), &tarball);
} else {

View file

@ -1203,6 +1203,7 @@ mod snapshot {
[build] rustc 1 <host> -> cargo 2 <host>
[dist] rustc 1 <host> -> cargo 2 <host>
[build] rustc 1 <host> -> rust-analyzer 2 <host>
[dist] rustc 1 <host> -> rust-analyzer 2 <host>
[build] rustc 1 <host> -> rustfmt 2 <host>
[build] rustc 1 <host> -> cargo-fmt 2 <host>
[build] rustc 1 <host> -> clippy-driver 2 <host>
@ -1533,6 +1534,7 @@ mod snapshot {
[build] rustc 1 <host> -> cargo 2 <target1>
[dist] rustc 1 <host> -> cargo 2 <target1>
[build] rustc 1 <host> -> rust-analyzer 2 <target1>
[dist] rustc 1 <host> -> rust-analyzer 2 <target1>
[build] rustc 1 <host> -> rustfmt 2 <target1>
[build] rustc 1 <host> -> cargo-fmt 2 <target1>
[build] rustc 1 <host> -> clippy-driver 2 <target1>