File tree Expand file tree Collapse file tree 4 files changed +39
-29
lines changed Expand file tree Collapse file tree 4 files changed +39
-29
lines changed Original file line number Diff line number Diff line change 1515//! switching compilers for the bootstrap and for build scripts will probably
1616//! never get replaced.
1717
18+ include ! ( "../dylib_util.rs" ) ;
19+
1820use std:: env;
1921use std:: path:: PathBuf ;
2022use std:: process:: { Child , Command } ;
@@ -50,11 +52,11 @@ fn main() {
5052
5153 let rustc = env:: var_os ( rustc) . unwrap_or_else ( || panic ! ( "{:?} was not set" , rustc) ) ;
5254 let libdir = env:: var_os ( libdir) . unwrap_or_else ( || panic ! ( "{:?} was not set" , libdir) ) ;
53- let mut dylib_path = bootstrap :: util :: dylib_path ( ) ;
55+ let mut dylib_path = dylib_path ( ) ;
5456 dylib_path. insert ( 0 , PathBuf :: from ( & libdir) ) ;
5557
5658 let mut cmd = Command :: new ( rustc) ;
57- cmd. args ( & args) . env ( bootstrap :: util :: dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
59+ cmd. args ( & args) . env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
5860
5961 // Get the name of the crate we're compiling, if any.
6062 let crate_name =
@@ -161,7 +163,7 @@ fn main() {
161163 eprintln ! (
162164 "{} command: {:?}={:?} {:?}" ,
163165 prefix,
164- bootstrap :: util :: dylib_path_var( ) ,
166+ dylib_path_var( ) ,
165167 env:: join_paths( & dylib_path) . unwrap( ) ,
166168 cmd,
167169 ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ use std::ffi::OsString;
77use std:: path:: PathBuf ;
88use std:: process:: Command ;
99
10+ include ! ( "../dylib_util.rs" ) ;
11+
1012fn main ( ) {
1113 let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
1214 let rustdoc = env:: var_os ( "RUSTDOC_REAL" ) . expect ( "RUSTDOC_REAL was not set" ) ;
@@ -20,14 +22,14 @@ fn main() {
2022 Err ( _) => 0 ,
2123 } ;
2224
23- let mut dylib_path = bootstrap :: util :: dylib_path ( ) ;
25+ let mut dylib_path = dylib_path ( ) ;
2426 dylib_path. insert ( 0 , PathBuf :: from ( libdir. clone ( ) ) ) ;
2527
2628 let mut cmd = Command :: new ( rustdoc) ;
2729 cmd. args ( & args)
2830 . arg ( "--sysroot" )
2931 . arg ( & sysroot)
30- . env ( bootstrap :: util :: dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
32+ . env ( dylib_path_var ( ) , env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
3133
3234 // Force all crates compiled by this compiler to (a) be unstable and (b)
3335 // allow the `rustc_private` feature to link to other unstable crates
@@ -59,7 +61,7 @@ fn main() {
5961 if verbose > 1 {
6062 eprintln ! (
6163 "rustdoc command: {:?}={:?} {:?}" ,
62- bootstrap :: util :: dylib_path_var( ) ,
64+ dylib_path_var( ) ,
6365 env:: join_paths( & dylib_path) . unwrap( ) ,
6466 cmd,
6567 ) ;
Original file line number Diff line number Diff line change 1+ // Various utilities for working with dylib paths.
2+ //
3+ // This file is meant to be included directly to avoid a dependency on the bootstrap library from
4+ // the rustc and rustdoc wrappers. This improves compilation time by reducing the linking time.
5+
6+ /// Returns the environment variable which the dynamic library lookup path
7+ /// resides in for this platform.
8+ pub fn dylib_path_var ( ) -> & ' static str {
9+ if cfg ! ( target_os = "windows" ) {
10+ "PATH"
11+ } else if cfg ! ( target_os = "macos" ) {
12+ "DYLD_LIBRARY_PATH"
13+ } else if cfg ! ( target_os = "haiku" ) {
14+ "LIBRARY_PATH"
15+ } else {
16+ "LD_LIBRARY_PATH"
17+ }
18+ }
19+
20+ /// Parses the `dylib_path_var()` environment variable, returning a list of
21+ /// paths that are members of this lookup path.
22+ pub fn dylib_path ( ) -> Vec < PathBuf > {
23+ let var = match env:: var_os ( dylib_path_var ( ) ) {
24+ Some ( v) => v,
25+ None => return vec ! [ ] ,
26+ } ;
27+ env:: split_paths ( & var) . collect ( )
28+ }
Original file line number Diff line number Diff line change @@ -54,29 +54,7 @@ pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
5454 cmd. env ( dylib_path_var ( ) , t ! ( env:: join_paths( list) ) ) ;
5555}
5656
57- /// Returns the environment variable which the dynamic library lookup path
58- /// resides in for this platform.
59- pub fn dylib_path_var ( ) -> & ' static str {
60- if cfg ! ( target_os = "windows" ) {
61- "PATH"
62- } else if cfg ! ( target_os = "macos" ) {
63- "DYLD_LIBRARY_PATH"
64- } else if cfg ! ( target_os = "haiku" ) {
65- "LIBRARY_PATH"
66- } else {
67- "LD_LIBRARY_PATH"
68- }
69- }
70-
71- /// Parses the `dylib_path_var()` environment variable, returning a list of
72- /// paths that are members of this lookup path.
73- pub fn dylib_path ( ) -> Vec < PathBuf > {
74- let var = match env:: var_os ( dylib_path_var ( ) ) {
75- Some ( v) => v,
76- None => return vec ! [ ] ,
77- } ;
78- env:: split_paths ( & var) . collect ( )
79- }
57+ include ! ( "dylib_util.rs" ) ;
8058
8159/// Adds a list of lookup paths to `cmd`'s link library lookup path.
8260pub fn add_link_lib_path ( path : Vec < PathBuf > , cmd : & mut Command ) {
You can’t perform that action at this time.
0 commit comments