Skip to content

Commit 9ef454a

Browse files
committed
remove bootstrap/dylib_util module
Signed-off-by: onur-ozkan <[email protected]>
1 parent 41cb42a commit 9ef454a

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
//! switching compilers for the bootstrap and for build scripts will probably
1616
//! never get replaced.
1717
18-
include!("../dylib_util.rs");
19-
2018
use std::env;
2119
use std::path::PathBuf;
2220
use std::process::{exit, Child, Command};
2321
use std::str::FromStr;
2422
use std::time::Instant;
2523

24+
use bootstrap::util::{dylib_path, dylib_path_var};
25+
2626
fn main() {
2727
let args = env::args_os().skip(1).collect::<Vec<_>>();
2828
let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str());

src/bootstrap/bin/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ffi::OsString;
77
use std::path::PathBuf;
88
use std::process::{exit, Command};
99

10-
include!("../dylib_util.rs");
10+
use bootstrap::util::{dylib_path, dylib_path_var};
1111

1212
fn main() {
1313
let args = env::args_os().skip(1).collect::<Vec<_>>();

src/bootstrap/dylib_util.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/bootstrap/util.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6394
pub 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.
87116
pub fn add_link_lib_path(path: Vec<PathBuf>, cmd: &mut Command) {
88117
let mut list = link_lib_path();

0 commit comments

Comments
 (0)