1
Fork 0

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.
This commit is contained in:
Amos Wenger 2022-07-26 16:25:48 +02:00
parent 8bcd4a2b4c
commit 6ea7d82dcc
3 changed files with 57 additions and 0 deletions

View file

@ -601,6 +601,7 @@ impl<'a> Builder<'a> {
tool::Cargo,
tool::Rls,
tool::RustAnalyzer,
tool::RustAnalyzerProcMacroSrv,
tool::RustDemangler,
tool::Rustdoc,
tool::Clippy,

View file

@ -362,6 +362,18 @@ impl Step for Rustc {
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
let ra_proc_macro_srv = builder
.ensure(tool::RustAnalyzerProcMacroSrv {
compiler: builder.compiler_for(
compiler.stage,
builder.config.build,
compiler.host,
),
target: compiler.host,
})
.expect("rust-analyzer-proc-macro-server always builds");
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
let libdir_relative = builder.libdir_relative(compiler);
// Copy runtime DLLs needed by the compiler

View file

@ -727,6 +727,50 @@ impl Step for RustAnalyzer {
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustAnalyzerProcMacroSrv {
pub compiler: Compiler,
pub target: TargetSelection,
}
impl Step for RustAnalyzerProcMacroSrv {
type Output = Option<PathBuf>;
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = false;
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")),
)
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustAnalyzerProcMacroSrv {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
target: run.target,
});
}
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
builder.ensure(ToolBuild {
compiler: self.compiler,
target: self.target,
tool: "rust-analyzer-proc-macro-srv",
mode: Mode::ToolStd,
path: "src/tools/rust-analyzer/crates/proc-macro-srv-cli",
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
is_optional_tool: false,
source_type: SourceType::InTree,
})
}
}
macro_rules! tool_extended {
(($sel:ident, $builder:ident),
$($name:ident,