diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-17 19:27:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-17 19:27:08 +0200 |
| commit | 179fd13e80bb1259a9bb0a3c49aab3d56217816a (patch) | |
| tree | df8dcb43e66d5ff2de399d13dc79c2e8b5eabb3f | |
| parent | 92d8bf918c6bc6b8e52043a66fea6e97c443436c (diff) | |
| parent | 9c3c88c94563ed9c42b7c6549c89e5fc8cc5615e (diff) | |
| download | rust-179fd13e80bb1259a9bb0a3c49aab3d56217816a.tar.gz rust-179fd13e80bb1259a9bb0a3c49aab3d56217816a.zip | |
Rollup merge of #101873 - WaffleLapkin:x-build-proc-macro-srv, r=jyn514
Allow building `rust-analyzer-proc-macro-srv` as a standalone tool
This PR allows building `rust-analyzer-proc-macro-srv` as a standalone tool via `x b proc-macro-srv-cli` (I thought that `x b rust-analyzer-proc-macro-srv` should work, but it doesn't for some reason...). Also this PR adds a copy of `rust-analyzer-proc-macro-srv` binary to `build/{triple}/{stage}/libexec/` when building `rust-analyzer-proc-macro-srv`, so that r-a can pick it up.
This is useful to make r-a (and I assume Intellij IDEA) to expand macros when using a custom, build from source toolchain.
r? ``@jyn514``
[_zulip thread_](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/How.20to.20fix.20.60UnsupportedABI.60.20for.20custom.20toolchains.3F/near/299040175)
| -rw-r--r-- | src/bootstrap/tool.rs | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 7d4ed24b648..5d0c7d2bd9d 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -746,14 +746,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<'_>) { @@ -764,7 +768,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", @@ -773,7 +777,15 @@ 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 `<sysroot>/libexec/` + // so that r-a can use it. + 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")); + + Some(path) } } |
