mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
run_make_support: make set_host_rpath
private and move into util
This commit is contained in:
parent
e956808c6c
commit
aadd08576d
@ -1,6 +1,7 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::{env_var, Command};
|
||||
use crate::command::Command;
|
||||
use crate::env_checked::env_var;
|
||||
|
||||
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
|
||||
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
|
||||
|
@ -1,8 +1,10 @@
|
||||
use command::Command;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{command, cwd, env_var, set_host_rpath};
|
||||
use crate::command::Command;
|
||||
use crate::env_checked::env_var;
|
||||
use crate::path_helpers::cwd;
|
||||
use crate::util::set_host_rpath;
|
||||
|
||||
/// Construct a new `rustc` invocation. This will automatically set the library
|
||||
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
|
||||
|
@ -2,7 +2,8 @@ use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::command::Command;
|
||||
use crate::{env_var, env_var_os, set_host_rpath};
|
||||
use crate::env_checked::{env_var, env_var_os};
|
||||
use crate::util::set_host_rpath;
|
||||
|
||||
/// Construct a plain `rustdoc` invocation with no flags set.
|
||||
#[track_caller]
|
||||
|
@ -20,8 +20,6 @@ pub mod run;
|
||||
pub mod scoped_run;
|
||||
pub mod targets;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
// Re-exports of third-party library crates.
|
||||
pub use bstr;
|
||||
pub use gimli;
|
||||
@ -85,8 +83,6 @@ pub use assertion_helpers::{
|
||||
shallow_find_files,
|
||||
};
|
||||
|
||||
use command::Command;
|
||||
|
||||
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
|
||||
#[track_caller]
|
||||
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
|
||||
@ -106,17 +102,3 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
|
||||
llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
|
||||
path(lib_path)
|
||||
}
|
||||
|
||||
/// Set the runtime library path as needed for running the host rustc/rustdoc/etc.
|
||||
pub fn set_host_rpath(cmd: &mut Command) {
|
||||
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
|
||||
cmd.env(&ld_lib_path_envvar, {
|
||||
let mut paths = vec![];
|
||||
paths.push(cwd());
|
||||
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
|
||||
for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) {
|
||||
paths.push(p.to_path_buf());
|
||||
}
|
||||
std::env::join_paths(paths.iter()).unwrap()
|
||||
});
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ use std::panic;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::command::{Command, CompletedProcess};
|
||||
use crate::util::handle_failed_output;
|
||||
use crate::{cwd, env_var, is_windows, set_host_rpath};
|
||||
use crate::util::{handle_failed_output, set_host_rpath};
|
||||
use crate::{cwd, env_var, is_windows};
|
||||
|
||||
#[track_caller]
|
||||
fn run_common(name: &str, args: Option<&[&str]>) -> Command {
|
||||
|
@ -1,4 +1,8 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::command::{Command, CompletedProcess};
|
||||
use crate::env_checked::env_var;
|
||||
use crate::path_helpers::cwd;
|
||||
|
||||
/// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the
|
||||
/// executed command, failure location, output status and stdout/stderr, and abort the process with
|
||||
@ -19,3 +23,17 @@ pub(crate) fn handle_failed_output(
|
||||
eprintln!("=== STDERR ===\n{}\n\n", output.stderr_utf8());
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
||||
/// Set the runtime library path as needed for running the host rustc/rustdoc/etc.
|
||||
pub(crate) fn set_host_rpath(cmd: &mut Command) {
|
||||
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
|
||||
cmd.env(&ld_lib_path_envvar, {
|
||||
let mut paths = vec![];
|
||||
paths.push(cwd());
|
||||
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
|
||||
for p in std::env::split_paths(&env_var(&ld_lib_path_envvar)) {
|
||||
paths.push(p.to_path_buf());
|
||||
}
|
||||
std::env::join_paths(paths.iter()).unwrap()
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user