Allow building rust-analyzer-proc-macro-srv as a standalone tool

This commit is contained in:
Maybe Waffle 2022-09-16 01:27:47 +04:00
parent 35a0407814
commit 532e3a50eb

View file

@ -745,14 +745,18 @@ impl Step for RustAnalyzerProcMacroSrv {
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.path("src/tools/rust-analyzer").default_condition(
builder.config.extended
&& builder
.config
.tools
.as_ref()
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
)
// Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
run.path("src/tools/rust-analyzer")
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
.default_condition(
builder.config.extended
&& builder.config.tools.as_ref().map_or(true, |tools| {
tools.iter().any(|tool| {
tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
})
}),
)
}
fn make_run(run: RunConfig<'_>) {
@ -763,7 +767,7 @@ impl Step for RustAnalyzerProcMacroSrv {
}
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
builder.ensure(ToolBuild {
let path = builder.ensure(ToolBuild {
compiler: self.compiler,
target: self.target,
tool: "rust-analyzer-proc-macro-srv",
@ -772,7 +776,19 @@ impl Step for RustAnalyzerProcMacroSrv {
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
is_optional_tool: false,
source_type: SourceType::InTree,
})
})?;
// Copy `rust-analyzer-proc-macro-srv` to `build/triple/stageN/libexec/`
// so that r-a can use it.
let libexec_path = builder
.out
.join(&*builder.config.build.triple)
.join(format!("stage{}", self.compiler.stage))
.join("libexec");
t!(fs::create_dir_all(&libexec_path));
builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));
Some(path)
}
}