Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions cargo/cargo_build_script_runner/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern crate cargo_build_script_output_parser;
use cargo_build_script_output_parser::{BuildScriptOutput, CompileAndLinkFlags};
use std::collections::BTreeMap;
use std::env;
use std::ffi::OsString;
use std::fs::{create_dir_all, read_to_string, write};
use std::path::Path;
use std::process::Command;
Expand Down Expand Up @@ -90,10 +89,10 @@ fn run_buildrs() -> Result<(), String> {
}

if let Some(cc_path) = env::var_os("CC") {
let mut cc_path = absolutify(&exec_root, cc_path);
let mut cc_path = exec_root.join(cc_path);
if let Some(sysroot_path) = env::var_os("SYSROOT") {
cc_path.push(" --sysroot=");
cc_path.push(absolutify(&exec_root, sysroot_path));
cc_path.push(&exec_root.join(sysroot_path));
}
command.env("CC", cc_path);
}
Expand All @@ -105,7 +104,7 @@ fn run_buildrs() -> Result<(), String> {
if Path::new(&ar_path).file_name() == Some("libtool".as_ref()) {
command.env_remove("AR");
} else {
command.env("AR", absolutify(&exec_root, ar_path));
command.env("AR", exec_root.join(ar_path));
}
}

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

fn absolutify(root: &Path, maybe_relative: OsString) -> OsString {
let path = Path::new(&maybe_relative);
if path.is_relative() {
root.join(path).into_os_string()
} else {
maybe_relative
}
}

fn main() {
std::process::exit(match run_buildrs() {
Ok(_) => 0,
Expand Down