]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/config.rs
Rollup merge of #48517 - penpalperson:master, r=Mark-Simulacrum
[rust.git] / src / bootstrap / config.rs
index 70a873043ad326ea15db2aa064ef9a921dcd7e99..6bc20181a0330a5a51eef0ae83defe310cb87e39 100644 (file)
@@ -17,7 +17,7 @@
 use std::env;
 use std::fs::File;
 use std::io::prelude::*;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
 use std::process;
 use std::cmp;
 
@@ -566,6 +566,17 @@ pub fn parse(args: &[String]) -> Config {
         config
     }
 
+    /// Try to find the relative path of `libdir`.
+    pub fn libdir_relative(&self) -> Option<&Path> {
+        let libdir = self.libdir.as_ref()?;
+        if libdir.is_relative() {
+            Some(libdir)
+        } else {
+            // Try to make it relative to the prefix.
+            libdir.strip_prefix(self.prefix.as_ref()?).ok()
+        }
+    }
+
     pub fn verbose(&self) -> bool {
         self.verbose > 0
     }