Support sysroot library source being defined inside the workspace

This commit is contained in:
Lukas Wirth 2023-02-06 12:07:33 +01:00
parent 0b32b65ca6
commit cb9a5b9549
6 changed files with 68 additions and 9 deletions

View file

@ -76,6 +76,7 @@ impl Sysroot {
}
}
// FIXME: Expose a builder api as loading the sysroot got way too modular and complicated.
impl Sysroot {
/// Attempts to discover the toolchain's sysroot from the given `dir`.
pub fn discover(dir: &AbsPath, extra_env: &FxHashMap<String, String>) -> Result<Sysroot> {
@ -86,6 +87,16 @@ impl Sysroot {
Ok(Sysroot::load(sysroot_dir, sysroot_src_dir))
}
pub fn discover_with_src_override(
dir: &AbsPath,
extra_env: &FxHashMap<String, String>,
src: AbsPathBuf,
) -> Result<Sysroot> {
tracing::debug!("discovering sysroot for {}", dir.display());
let sysroot_dir = discover_sysroot_dir(dir, extra_env)?;
Ok(Sysroot::load(sysroot_dir, src))
}
pub fn discover_rustc(
cargo_toml: &ManifestPath,
extra_env: &FxHashMap<String, String>,