Skip to content

Commit

Permalink
Clean up Config::libdir_relative
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Feb 25, 2018
1 parent a174d0e commit d7e8200
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ impl<'a> Builder<'a> {
fn run(self, builder: &Builder) -> Interned<PathBuf> {
let compiler = self.compiler;
let config = &builder.build.config;
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
config.libdir_relative().unwrap()
let lib = if compiler.stage >= 1 {
config.libdir_relative()
} else {
Path::new("lib")
};
Expand Down Expand Up @@ -736,7 +736,7 @@ impl<'a> Builder<'a> {
.env("CFG_VERSION", self.rust_version())
.env("CFG_PREFIX", &self.config.install.prefix);

let libdir_relative = self.config.libdir_relative().unwrap_or(Path::new("lib"));
let libdir_relative = self.config.libdir_relative();
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);

// If we're not building a compiler with debugging information then remove
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ impl Config {
}

/// Try to find the relative path of `libdir`.
pub fn libdir_relative(&self) -> Option<&Path> {
let libdir = self.install.libdir.as_ref()?;
pub fn libdir_relative(&self) -> &Path {
let libdir = &self.install.libdir;
if libdir.is_relative() {
Some(libdir)
libdir
} else {
// Try to make it relative to the prefix.
libdir.strip_prefix(self.prefix.as_ref()?).ok()
libdir.strip_prefix(&self.install.prefix).unwrap_or(Path::new("lib"))
}
}

Expand Down

0 comments on commit d7e8200

Please sign in to comment.