Skip to content

Commit 532e3a5

Browse files
committed
Allow building rust-analyzer-proc-macro-srv as a standalone tool
1 parent 35a0407 commit 532e3a5

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/bootstrap/tool.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,18 @@ impl Step for RustAnalyzerProcMacroSrv {
745745

746746
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
747747
let builder = run.builder;
748-
run.path("src/tools/rust-analyzer").default_condition(
749-
builder.config.extended
750-
&& builder
751-
.config
752-
.tools
753-
.as_ref()
754-
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
755-
)
748+
749+
// Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
750+
run.path("src/tools/rust-analyzer")
751+
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
752+
.default_condition(
753+
builder.config.extended
754+
&& builder.config.tools.as_ref().map_or(true, |tools| {
755+
tools.iter().any(|tool| {
756+
tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
757+
})
758+
}),
759+
)
756760
}
757761

758762
fn make_run(run: RunConfig<'_>) {
@@ -763,7 +767,7 @@ impl Step for RustAnalyzerProcMacroSrv {
763767
}
764768

765769
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
766-
builder.ensure(ToolBuild {
770+
let path = builder.ensure(ToolBuild {
767771
compiler: self.compiler,
768772
target: self.target,
769773
tool: "rust-analyzer-proc-macro-srv",
@@ -772,7 +776,19 @@ impl Step for RustAnalyzerProcMacroSrv {
772776
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
773777
is_optional_tool: false,
774778
source_type: SourceType::InTree,
775-
})
779+
})?;
780+
781+
// Copy `rust-analyzer-proc-macro-srv` to `build/triple/stageN/libexec/`
782+
// so that r-a can use it.
783+
let libexec_path = builder
784+
.out
785+
.join(&*builder.config.build.triple)
786+
.join(format!("stage{}", self.compiler.stage))
787+
.join("libexec");
788+
t!(fs::create_dir_all(&libexec_path));
789+
builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));
790+
791+
Some(path)
776792
}
777793
}
778794

0 commit comments

Comments
 (0)