@@ -59,6 +59,37 @@ pub fn is_dylib(name: &str) -> bool {
5959 name. ends_with ( ".dylib" ) || name. ends_with ( ".so" ) || name. ends_with ( ".dll" )
6060}
6161
62+ // Various utilities for working with dylib paths.
63+ //
64+ // This file is meant to be included directly to avoid a dependency on the bootstrap library from
65+ // the rustc and rustdoc wrappers. This improves compilation time by reducing the linking time.
66+
67+ /// Returns the environment variable which the dynamic library lookup path
68+ /// resides in for this platform.
69+ pub fn dylib_path_var ( ) -> & ' static str {
70+ if cfg ! ( target_os = "windows" ) {
71+ "PATH"
72+ } else if cfg ! ( target_os = "macos" ) {
73+ "DYLD_LIBRARY_PATH"
74+ } else if cfg ! ( target_os = "haiku" ) {
75+ "LIBRARY_PATH"
76+ } else if cfg ! ( target_os = "aix" ) {
77+ "LIBPATH"
78+ } else {
79+ "LD_LIBRARY_PATH"
80+ }
81+ }
82+
83+ /// Parses the `dylib_path_var()` environment variable, returning a list of
84+ /// paths that are members of this lookup path.
85+ pub fn dylib_path ( ) -> Vec < PathBuf > {
86+ let var = match env:: var_os ( dylib_path_var ( ) ) {
87+ Some ( v) => v,
88+ None => return vec ! [ ] ,
89+ } ;
90+ env:: split_paths ( & var) . collect ( )
91+ }
92+
6293/// Returns `true` if the file name given looks like a debug info file
6394pub fn is_debug_info ( name : & str ) -> bool {
6495 // FIXME: consider split debug info on other platforms (e.g., Linux, macOS)
@@ -81,8 +112,6 @@ pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
81112 cmd. env ( dylib_path_var ( ) , t ! ( env:: join_paths( list) ) ) ;
82113}
83114
84- include ! ( "dylib_util.rs" ) ;
85-
86115/// Adds a list of lookup paths to `cmd`'s link library lookup path.
87116pub fn add_link_lib_path ( path : Vec < PathBuf > , cmd : & mut Command ) {
88117 let mut list = link_lib_path ( ) ;
0 commit comments