@@ -17,7 +17,7 @@ use std::collections::{HashMap, HashSet};
1717use std:: env;
1818use std:: fs:: File ;
1919use std:: io:: prelude:: * ;
20- use std:: path:: PathBuf ;
20+ use std:: path:: { Path , PathBuf } ;
2121use std:: process;
2222use std:: cmp;
2323
@@ -126,7 +126,6 @@ pub struct Config {
126126 pub docdir : Option < PathBuf > ,
127127 pub bindir : Option < PathBuf > ,
128128 pub libdir : Option < PathBuf > ,
129- pub libdir_relative : Option < PathBuf > ,
130129 pub mandir : Option < PathBuf > ,
131130 pub codegen_tests : bool ,
132131 pub nodejs : Option < PathBuf > ,
@@ -418,22 +417,6 @@ impl Config {
418417 config. mandir = install. mandir . clone ( ) . map ( PathBuf :: from) ;
419418 }
420419
421- // Try to infer `libdir_relative` from `libdir`.
422- if let Some ( ref libdir) = config. libdir {
423- let mut libdir = libdir. as_path ( ) ;
424- if !libdir. is_relative ( ) {
425- // Try to make it relative to the prefix.
426- if let Some ( ref prefix) = config. prefix {
427- if let Ok ( suffix) = libdir. strip_prefix ( prefix) {
428- libdir = suffix;
429- }
430- }
431- }
432- if libdir. is_relative ( ) {
433- config. libdir_relative = Some ( libdir. to_path_buf ( ) ) ;
434- }
435- }
436-
437420 // Store off these values as options because if they're not provided
438421 // we'll infer default values for them later
439422 let mut thinlto = None ;
@@ -581,6 +564,17 @@ impl Config {
581564 config
582565 }
583566
567+ /// Try to find the relative path of `libdir`.
568+ pub fn libdir_relative ( & self ) -> Option < & Path > {
569+ let libdir = self . libdir . as_ref ( ) ?;
570+ if libdir. is_relative ( ) {
571+ Some ( libdir)
572+ } else {
573+ // Try to make it relative to the prefix.
574+ libdir. strip_prefix ( self . prefix . as_ref ( ) ?) . ok ( )
575+ }
576+ }
577+
584578 pub fn verbose ( & self ) -> bool {
585579 self . verbose > 0
586580 }
0 commit comments