Pass all-targets for build scripts in more cli commands

Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
This commit is contained in:
Lukas Wirth 2024-09-25 08:16:22 +02:00
parent 2f55a91552
commit 10ada02019
7 changed files with 30 additions and 12 deletions

View file

@ -109,7 +109,7 @@ impl fmt::Debug for ProjectWorkspace {
ProjectWorkspaceKind::Cargo { ProjectWorkspaceKind::Cargo {
cargo, cargo,
error: _, error: _,
build_scripts: _, build_scripts,
rustc, rustc,
cargo_config_extra_env, cargo_config_extra_env,
} => f } => f
@ -126,6 +126,7 @@ impl fmt::Debug for ProjectWorkspace {
.field("toolchain", &toolchain) .field("toolchain", &toolchain)
.field("data_layout", &target_layout) .field("data_layout", &target_layout)
.field("cargo_config_extra_env", &cargo_config_extra_env) .field("cargo_config_extra_env", &cargo_config_extra_env)
.field("build_scripts", &build_scripts.error().unwrap_or("ok"))
.finish(), .finish(),
ProjectWorkspaceKind::Json(project) => { ProjectWorkspaceKind::Json(project) => {
let mut debug_struct = f.debug_struct("Json"); let mut debug_struct = f.debug_struct("Json");

View file

@ -64,6 +64,7 @@ impl flags::AnalysisStats {
true => None, true => None,
false => Some(RustLibSource::Discover), false => Some(RustLibSource::Discover),
}, },
all_targets: true,
..Default::default() ..Default::default()
}; };
let no_progress = &|_| (); let no_progress = &|_| ();
@ -343,6 +344,7 @@ impl flags::AnalysisStats {
true => None, true => None,
false => Some(RustLibSource::Discover), false => Some(RustLibSource::Discover),
}, },
all_targets: true,
..Default::default() ..Default::default()
}; };

View file

@ -24,8 +24,11 @@ impl flags::Diagnostics {
handle.join() handle.join()
} }
fn run_(self) -> anyhow::Result<()> { fn run_(self) -> anyhow::Result<()> {
let cargo_config = let cargo_config = CargoConfig {
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; sysroot: Some(RustLibSource::Discover),
all_targets: true,
..Default::default()
};
let with_proc_macro_server = if let Some(p) = &self.proc_macro_srv { let with_proc_macro_server = if let Some(p) = &self.proc_macro_srv {
let path = vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(p)); let path = vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(p));
ProcMacroServerChoice::Explicit(path) ProcMacroServerChoice::Explicit(path)

View file

@ -273,10 +273,12 @@ impl LsifManager<'_> {
impl flags::Lsif { impl flags::Lsif {
pub fn run(self) -> anyhow::Result<()> { pub fn run(self) -> anyhow::Result<()> {
eprintln!("Generating LSIF started...");
let now = Instant::now(); let now = Instant::now();
let cargo_config = let cargo_config = &CargoConfig {
&CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; sysroot: Some(RustLibSource::Discover),
all_targets: true,
..Default::default()
};
let no_progress = &|_| (); let no_progress = &|_| ();
let load_cargo_config = LoadCargoConfig { let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true, load_out_dirs_from_check: true,
@ -285,6 +287,7 @@ impl flags::Lsif {
}; };
let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path)); let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path));
let root = ProjectManifest::discover_single(&path)?; let root = ProjectManifest::discover_single(&path)?;
eprintln!("Generating LSIF for project at {root}");
let mut workspace = ProjectWorkspace::load(root, cargo_config, no_progress)?; let mut workspace = ProjectWorkspace::load(root, cargo_config, no_progress)?;
let build_scripts = workspace.run_build_scripts(cargo_config, no_progress)?; let build_scripts = workspace.run_build_scripts(cargo_config, no_progress)?;

View file

@ -13,8 +13,11 @@ use crate::cli::{flags, full_name_of_item, Result};
impl flags::RunTests { impl flags::RunTests {
pub fn run(self) -> Result<()> { pub fn run(self) -> Result<()> {
let cargo_config = let cargo_config = CargoConfig {
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; sysroot: Some(RustLibSource::Discover),
all_targets: true,
..Default::default()
};
let load_cargo_config = LoadCargoConfig { let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true, load_out_dirs_from_check: true,
with_proc_macro_server: ProcMacroServerChoice::Sysroot, with_proc_macro_server: ProcMacroServerChoice::Sysroot,

View file

@ -67,8 +67,11 @@ impl Tester {
path.push("ra-rustc-test.rs"); path.push("ra-rustc-test.rs");
let tmp_file = AbsPathBuf::try_from(Utf8PathBuf::from_path_buf(path).unwrap()).unwrap(); let tmp_file = AbsPathBuf::try_from(Utf8PathBuf::from_path_buf(path).unwrap()).unwrap();
std::fs::write(&tmp_file, "")?; std::fs::write(&tmp_file, "")?;
let cargo_config = let cargo_config = CargoConfig {
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; sysroot: Some(RustLibSource::Discover),
all_targets: true,
..Default::default()
};
let sysroot = Sysroot::discover(tmp_file.parent().unwrap(), &cargo_config.extra_env); let sysroot = Sysroot::discover(tmp_file.parent().unwrap(), &cargo_config.extra_env);
let data_layout = target_data_layout::get( let data_layout = target_data_layout::get(

View file

@ -10,8 +10,11 @@ use crate::cli::flags;
impl flags::Ssr { impl flags::Ssr {
pub fn run(self) -> anyhow::Result<()> { pub fn run(self) -> anyhow::Result<()> {
let cargo_config = let cargo_config = CargoConfig {
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() }; sysroot: Some(RustLibSource::Discover),
all_targets: true,
..Default::default()
};
let load_cargo_config = LoadCargoConfig { let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true, load_out_dirs_from_check: true,
with_proc_macro_server: ProcMacroServerChoice::Sysroot, with_proc_macro_server: ProcMacroServerChoice::Sysroot,