]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/config.rs
Simplify Cache wrapper to single type, impl Deref on it, fix all compilation errors...
[rust.git] / src / bootstrap / config.rs
index d1bdfa0a7676309ccd0209ea4ac8bd8397f358de..0c03b95c7b251035eb5f7ce4936877b65f481f14 100644 (file)
@@ -647,6 +647,20 @@ pub fn parse(args: &[String]) -> Config {
         config
     }
 
+    /// 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_absolute() {
+            // Try to make it relative to the prefix.
+            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`.
     pub fn libdir_relative(&self) -> Option<&Path> {
         let libdir = self.libdir.as_ref()?;