From 532e3a50ebf5ed0b2c6b097bab5fc34ee576216f Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 16 Sep 2022 01:27:47 +0400 Subject: [PATCH 1/2] Allow building `rust-analyzer-proc-macro-srv` as a standalone tool --- src/bootstrap/tool.rs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index c3b04a9bbce3f..77109659ca7e6 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -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 { - 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) } } From 9c3c88c94563ed9c42b7c6549c89e5fc8cc5615e Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 16 Sep 2022 11:10:20 +0400 Subject: [PATCH 2/2] Use `builder.sysroot(...)` instead of a hack --- src/bootstrap/tool.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 77109659ca7e6..d603f2bb8ab07 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -778,13 +778,9 @@ impl Step for RustAnalyzerProcMacroSrv { source_type: SourceType::InTree, })?; - // Copy `rust-analyzer-proc-macro-srv` to `build/triple/stageN/libexec/` + // Copy `rust-analyzer-proc-macro-srv` to `/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"); + let libexec_path = builder.sysroot(self.compiler).join("libexec"); t!(fs::create_dir_all(&libexec_path)); builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));