Convert rust-analyzer to 'in-tree' tool, pass 'in-rust-tree' feature by default

This commit is contained in:
Amos Wenger 2022-07-22 15:38:45 +02:00
parent 43acb501b9
commit 0f2266d3cc
3 changed files with 47 additions and 4 deletions

View File

@ -1551,7 +1551,7 @@ impl<'a> Builder<'a> {
Mode::ToolStd => {
// Right now this is just compiletest and a few other tools that build on stable.
// Allow them to use `feature(test)`, but nothing else.
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace");
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace,proc_macro_internals,proc_macro_diagnostic,proc_macro_span");
}
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {}
}

View File

@ -1058,7 +1058,7 @@ impl Step for RustAnalyzer {
}
let rust_analyzer = builder
.ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() })
.ensure(tool::RustAnalyzer { compiler, target })
.expect("rust-analyzer always builds");
let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);

View File

@ -1,7 +1,7 @@
use std::collections::HashSet;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::process::Command;
use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
@ -683,6 +683,50 @@ impl Step for LldWrapper {
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustAnalyzer {
pub compiler: Compiler,
pub target: TargetSelection,
}
impl Step for RustAnalyzer {
type Output = Option<PathBuf>;
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.path("src/tools/rust-analyzer/crates/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(RustAnalyzer {
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",
mode: Mode::ToolStd,
path: "src/tools/rust-analyzer/crates/rust-analyzer",
extra_features: vec!["in-rust-tree".to_owned()],
is_optional_tool: true,
source_type: SourceType::InTree,
})
}
}
macro_rules! tool_extended {
(($sel:ident, $builder:ident),
$($name:ident,
@ -780,7 +824,6 @@ tool_extended!((self, builder),
// and this is close enough for now.
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=true, submodule="rust-analyzer", {};
);
impl<'a> Builder<'a> {