Skip to content

Commit 6ea7d82

Browse files
Ship rust-analyzer-proc-macro-srv binary with dist::Rustc
This builds `src/tools/rust-analyzer/crates/proc-macro-srv-cli` and ships it as part of Rustc's dist component. This allows rust-analyzer's proc macro support to work on all rustc versions (stable, beta and nightly) starting now.
1 parent 8bcd4a2 commit 6ea7d82

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

Diff for: src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ impl<'a> Builder<'a> {
601601
tool::Cargo,
602602
tool::Rls,
603603
tool::RustAnalyzer,
604+
tool::RustAnalyzerProcMacroSrv,
604605
tool::RustDemangler,
605606
tool::Rustdoc,
606607
tool::Clippy,

Diff for: src/bootstrap/dist.rs

+12
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,18 @@ impl Step for Rustc {
362362

363363
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
364364

365+
let ra_proc_macro_srv = builder
366+
.ensure(tool::RustAnalyzerProcMacroSrv {
367+
compiler: builder.compiler_for(
368+
compiler.stage,
369+
builder.config.build,
370+
compiler.host,
371+
),
372+
target: compiler.host,
373+
})
374+
.expect("rust-analyzer-proc-macro-server always builds");
375+
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
376+
365377
let libdir_relative = builder.libdir_relative(compiler);
366378

367379
// Copy runtime DLLs needed by the compiler

Diff for: src/bootstrap/tool.rs

+44
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,50 @@ impl Step for RustAnalyzer {
727727
}
728728
}
729729

730+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
731+
pub struct RustAnalyzerProcMacroSrv {
732+
pub compiler: Compiler,
733+
pub target: TargetSelection,
734+
}
735+
736+
impl Step for RustAnalyzerProcMacroSrv {
737+
type Output = Option<PathBuf>;
738+
const DEFAULT: bool = true;
739+
const ONLY_HOSTS: bool = false;
740+
741+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
742+
let builder = run.builder;
743+
run.path("src/tools/rust-analyzer").default_condition(
744+
builder.config.extended
745+
&& builder
746+
.config
747+
.tools
748+
.as_ref()
749+
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
750+
)
751+
}
752+
753+
fn make_run(run: RunConfig<'_>) {
754+
run.builder.ensure(RustAnalyzerProcMacroSrv {
755+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
756+
target: run.target,
757+
});
758+
}
759+
760+
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
761+
builder.ensure(ToolBuild {
762+
compiler: self.compiler,
763+
target: self.target,
764+
tool: "rust-analyzer-proc-macro-srv",
765+
mode: Mode::ToolStd,
766+
path: "src/tools/rust-analyzer/crates/proc-macro-srv-cli",
767+
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
768+
is_optional_tool: false,
769+
source_type: SourceType::InTree,
770+
})
771+
}
772+
}
773+
730774
macro_rules! tool_extended {
731775
(($sel:ident, $builder:ident),
732776
$($name:ident,

0 commit comments

Comments
 (0)