Add config for supplying sysroot path

This commit is contained in:
Lukas Wirth 2022-10-01 20:47:31 +02:00
parent bf5cad8e77
commit 5424c51158
10 changed files with 88 additions and 41 deletions

View file

@ -188,17 +188,26 @@ impl ProjectWorkspace {
})?;
let cargo = CargoWorkspace::new(meta);
let sysroot = if config.no_sysroot {
None
} else {
Some(Sysroot::discover(cargo_toml.parent(), &config.extra_env).with_context(
|| {
let sysroot = match &config.sysroot {
Some(RustcSource::Path(path)) => {
Some(Sysroot::with_sysroot_dir(path.clone()).with_context(|| {
format!(
"Failed to find sysroot for Cargo.toml file {}.",
cargo_toml.display()
)
})?)
}
Some(RustcSource::Discover) => Some(
Sysroot::discover(cargo_toml.parent(), &config.extra_env).with_context(
|| {
format!(
"Failed to find sysroot for Cargo.toml file {}. Is rust-src installed?",
cargo_toml.display()
)
},
)?)
},
)?,
),
None => None,
};
let rustc_dir = match &config.rustc_source {