Skip to content

Commit 4769fc9

Browse files
committed
run_make_support: make set_host_rpath private and move into util
1 parent 4586364 commit 4769fc9

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

src/tools/run-make-support/src/external_deps/llvm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::path::{Path, PathBuf};
22

3-
use crate::{env_var, Command};
3+
use crate::command::Command;
4+
use crate::env_checked::env_var;
45

56
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
67
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.

src/tools/run-make-support/src/external_deps/rustc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use command::Command;
21
use std::ffi::{OsStr, OsString};
32
use std::path::Path;
43

5-
use crate::{command, cwd, env_var, set_host_rpath};
4+
use crate::command::Command;
5+
use crate::env_checked::env_var;
6+
use crate::path_helpers::cwd;
7+
use crate::util::set_host_rpath;
68

79
/// Construct a new `rustc` invocation. This will automatically set the library
810
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.

src/tools/run-make-support/src/external_deps/rustdoc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use std::ffi::OsStr;
22
use std::path::Path;
33

44
use crate::command::Command;
5-
use crate::{env_var, env_var_os, set_host_rpath};
5+
use crate::env_checked::{env_var, env_var_os};
6+
use crate::util::set_host_rpath;
67

78
/// Construct a plain `rustdoc` invocation with no flags set.
89
#[track_caller]

src/tools/run-make-support/src/lib.rs

-18
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ pub mod run;
2020
pub mod scoped_run;
2121
pub mod targets;
2222

23-
use std::path::PathBuf;
24-
2523
// Re-exports of third-party library crates.
2624
pub use bstr;
2725
pub use gimli;
@@ -84,19 +82,3 @@ pub use assertion_helpers::{
8482
has_prefix, has_suffix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains,
8583
shallow_find_files,
8684
};
87-
88-
use command::Command;
89-
90-
/// Set the runtime library path as needed for running the host rustc/rustdoc/etc.
91-
pub fn set_host_rpath(cmd: &mut Command) {
92-
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
93-
cmd.env(&ld_lib_path_envvar, {
94-
let mut paths = vec![];
95-
paths.push(cwd());
96-
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
97-
for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) {
98-
paths.push(p.to_path_buf());
99-
}
100-
std::env::join_paths(paths.iter()).unwrap()
101-
});
102-
}

src/tools/run-make-support/src/run.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::panic;
44
use std::path::{Path, PathBuf};
55

66
use crate::command::{Command, CompletedProcess};
7-
use crate::util::handle_failed_output;
8-
use crate::{cwd, env_var, is_windows, set_host_rpath};
7+
use crate::util::{handle_failed_output, set_host_rpath};
8+
use crate::{cwd, env_var, is_windows};
99

1010
#[track_caller]
1111
fn run_common(name: &str, args: Option<&[&str]>) -> Command {

src/tools/run-make-support/src/util.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
use std::path::PathBuf;
2+
13
use crate::command::{Command, CompletedProcess};
4+
use crate::env_checked::env_var;
5+
use crate::path_helpers::cwd;
26

37
/// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the
48
/// executed command, failure location, output status and stdout/stderr, and abort the process with
@@ -19,3 +23,17 @@ pub(crate) fn handle_failed_output(
1923
eprintln!("=== STDERR ===\n{}\n\n", output.stderr_utf8());
2024
std::process::exit(1)
2125
}
26+
27+
/// Set the runtime library path as needed for running the host rustc/rustdoc/etc.
28+
pub(crate) fn set_host_rpath(cmd: &mut Command) {
29+
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
30+
cmd.env(&ld_lib_path_envvar, {
31+
let mut paths = vec![];
32+
paths.push(cwd());
33+
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
34+
for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) {
35+
paths.push(p.to_path_buf());
36+
}
37+
std::env::join_paths(paths.iter()).unwrap()
38+
});
39+
}

0 commit comments

Comments
 (0)