Skip to content

Commit 179fd13

Browse files
authoredSep 17, 2022
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)
2 parents 92d8bf9 + 9c3c88c commit 179fd13

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed
 

‎src/bootstrap/tool.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -746,14 +746,18 @@ impl Step for RustAnalyzerProcMacroSrv {
746746

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

759763
fn make_run(run: RunConfig<'_>) {
@@ -764,7 +768,7 @@ impl Step for RustAnalyzerProcMacroSrv {
764768
}
765769

766770
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
767-
builder.ensure(ToolBuild {
771+
let path = builder.ensure(ToolBuild {
768772
compiler: self.compiler,
769773
target: self.target,
770774
tool: "rust-analyzer-proc-macro-srv",
@@ -773,7 +777,15 @@ impl Step for RustAnalyzerProcMacroSrv {
773777
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
774778
is_optional_tool: false,
775779
source_type: SourceType::InTree,
776-
})
780+
})?;
781+
782+
// Copy `rust-analyzer-proc-macro-srv` to `<sysroot>/libexec/`
783+
// so that r-a can use it.
784+
let libexec_path = builder.sysroot(self.compiler).join("libexec");
785+
t!(fs::create_dir_all(&libexec_path));
786+
builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));
787+
788+
Some(path)
777789
}
778790
}
779791

0 commit comments

Comments
 (0)
Please sign in to comment.