Fallback to the unmodified path in bindir_relative

This commit is contained in:
Josh Stone 2019-11-12 09:42:46 -08:00
parent 1aee3e4d08
commit bfa5e5f788
2 changed files with 10 additions and 8 deletions

View File

@ -1232,8 +1232,7 @@ impl<'a> Builder<'a> {
}
// Try to use a sysroot-relative bindir, in case it was configured absolutely.
let bindir = self.config.bindir_relative().unwrap_or(&self.config.bindir);
cargo.env("RUSTC_INSTALL_BINDIR", bindir);
cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
self.ci_env.force_coloring_in_ci(&mut cargo);

View File

@ -647,15 +647,18 @@ impl Config {
config
}
/// Try to find the relative path of `bindir`.
pub fn bindir_relative(&self) -> Option<&Path> {
/// Try to find the relative path of `bindir`, otherwise return it in full.
pub fn bindir_relative(&self) -> &Path {
let bindir = &self.bindir;
if bindir.is_relative() {
Some(bindir)
} else {
if bindir.is_absolute() {
// Try to make it relative to the prefix.
bindir.strip_prefix(self.prefix.as_ref()?).ok()
if let Some(prefix) = &self.prefix {
if let Ok(stripped) = bindir.strip_prefix(prefix) {
return stripped;
}
}
}
bindir
}
/// Try to find the relative path of `libdir`.