Skip to content

Commit 4efa71d

Browse files
authored
Remove absolutify (#973)
This is the built-in behaviour of `Path::join`.
1 parent 2c88055 commit 4efa71d

File tree

1 file changed

+3
-13
lines changed
  • cargo/cargo_build_script_runner

1 file changed

+3
-13
lines changed

cargo/cargo_build_script_runner/bin.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ extern crate cargo_build_script_output_parser;
1919
use cargo_build_script_output_parser::{BuildScriptOutput, CompileAndLinkFlags};
2020
use std::collections::BTreeMap;
2121
use std::env;
22-
use std::ffi::OsString;
2322
use std::fs::{create_dir_all, read_to_string, write};
2423
use std::path::Path;
2524
use std::process::Command;
@@ -90,10 +89,10 @@ fn run_buildrs() -> Result<(), String> {
9089
}
9190

9291
if let Some(cc_path) = env::var_os("CC") {
93-
let mut cc_path = absolutify(&exec_root, cc_path);
92+
let mut cc_path = exec_root.join(cc_path);
9493
if let Some(sysroot_path) = env::var_os("SYSROOT") {
9594
cc_path.push(" --sysroot=");
96-
cc_path.push(absolutify(&exec_root, sysroot_path));
95+
cc_path.push(&exec_root.join(sysroot_path));
9796
}
9897
command.env("CC", cc_path);
9998
}
@@ -105,7 +104,7 @@ fn run_buildrs() -> Result<(), String> {
105104
if Path::new(&ar_path).file_name() == Some("libtool".as_ref()) {
106105
command.env_remove("AR");
107106
} else {
108-
command.env("AR", absolutify(&exec_root, ar_path));
107+
command.env("AR", exec_root.join(ar_path));
109108
}
110109
}
111110

@@ -258,15 +257,6 @@ fn get_target_env_vars<P: AsRef<Path>>(rustc: &P) -> Result<BTreeMap<String, Str
258257
.collect())
259258
}
260259

261-
fn absolutify(root: &Path, maybe_relative: OsString) -> OsString {
262-
let path = Path::new(&maybe_relative);
263-
if path.is_relative() {
264-
root.join(path).into_os_string()
265-
} else {
266-
maybe_relative
267-
}
268-
}
269-
270260
fn main() {
271261
std::process::exit(match run_buildrs() {
272262
Ok(_) => 0,

0 commit comments

Comments
 (0)