File tree 4 files changed +39
-29
lines changed
4 files changed +39
-29
lines changed Original file line number Diff line number Diff line change 15
15
//! switching compilers for the bootstrap and for build scripts will probably
16
16
//! never get replaced.
17
17
18
+ include ! ( "../dylib_util.rs" ) ;
19
+
18
20
use std:: env;
19
21
use std:: path:: PathBuf ;
20
22
use std:: process:: { Child , Command } ;
@@ -50,11 +52,11 @@ fn main() {
50
52
51
53
let rustc = env:: var_os ( rustc) . unwrap_or_else ( || panic ! ( "{:?} was not set" , rustc) ) ;
52
54
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 ( ) ;
54
56
dylib_path. insert ( 0 , PathBuf :: from ( & libdir) ) ;
55
57
56
58
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 ( ) ) ;
58
60
59
61
// Get the name of the crate we're compiling, if any.
60
62
let crate_name =
@@ -161,7 +163,7 @@ fn main() {
161
163
eprintln ! (
162
164
"{} command: {:?}={:?} {:?}" ,
163
165
prefix,
164
- bootstrap :: util :: dylib_path_var( ) ,
166
+ dylib_path_var( ) ,
165
167
env:: join_paths( & dylib_path) . unwrap( ) ,
166
168
cmd,
167
169
) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ use std::ffi::OsString;
7
7
use std:: path:: PathBuf ;
8
8
use std:: process:: Command ;
9
9
10
+ include ! ( "../dylib_util.rs" ) ;
11
+
10
12
fn main ( ) {
11
13
let args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
12
14
let rustdoc = env:: var_os ( "RUSTDOC_REAL" ) . expect ( "RUSTDOC_REAL was not set" ) ;
@@ -20,14 +22,14 @@ fn main() {
20
22
Err ( _) => 0 ,
21
23
} ;
22
24
23
- let mut dylib_path = bootstrap :: util :: dylib_path ( ) ;
25
+ let mut dylib_path = dylib_path ( ) ;
24
26
dylib_path. insert ( 0 , PathBuf :: from ( libdir. clone ( ) ) ) ;
25
27
26
28
let mut cmd = Command :: new ( rustdoc) ;
27
29
cmd. args ( & args)
28
30
. arg ( "--sysroot" )
29
31
. 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 ( ) ) ;
31
33
32
34
// Force all crates compiled by this compiler to (a) be unstable and (b)
33
35
// allow the `rustc_private` feature to link to other unstable crates
@@ -59,7 +61,7 @@ fn main() {
59
61
if verbose > 1 {
60
62
eprintln ! (
61
63
"rustdoc command: {:?}={:?} {:?}" ,
62
- bootstrap :: util :: dylib_path_var( ) ,
64
+ dylib_path_var( ) ,
63
65
env:: join_paths( & dylib_path) . unwrap( ) ,
64
66
cmd,
65
67
) ;
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) {
54
54
cmd. env ( dylib_path_var ( ) , t ! ( env:: join_paths( list) ) ) ;
55
55
}
56
56
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" ) ;
80
58
81
59
/// Adds a list of lookup paths to `cmd`'s link library lookup path.
82
60
pub fn add_link_lib_path ( path : Vec < PathBuf > , cmd : & mut Command ) {
You can’t perform that action at this time.
0 commit comments