Skip to content

Commit

Permalink
Fixed unresolved pwd template
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Mar 4, 2022
1 parent 37819f7 commit bf48102
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 10 additions & 9 deletions cargo/cargo_build_script_runner/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ fn run_buildrs() -> Result<(), String> {
}
}

// Bazel does not support byte strings so in order to correctly represent `CARGO_ENCODED_RUSTFLAGS`
// the escaped `\x1f` sequences need to be unescaped
if let Ok(encoded_rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
command.env(
"CARGO_ENCODED_RUSTFLAGS",
encoded_rustflags.replace("\\x1f", "\x1f"),
);
}

if let Some(ar_path) = env::var_os("AR") {
// The default OSX toolchain uses libtool as ar_executable not ar.
// This doesn't work when used as $AR, so simply don't set it - tools will probably fall back to
Expand All @@ -132,6 +123,16 @@ fn run_buildrs() -> Result<(), String> {
}
}

// Bazel does not support byte strings so in order to correctly represent `CARGO_ENCODED_RUSTFLAGS`
// the escaped `\x1f` sequences need to be unescaped
if let Ok(encoded_rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
command.env(
"CARGO_ENCODED_RUSTFLAGS",
encoded_rustflags
.replace("\\x1f", "\x1f"),
);
}

let (buildrs_outputs, process_output) = BuildScriptOutput::outputs_from_command(&mut command)
.map_err(|process_output| {
format!(
Expand Down
5 changes: 4 additions & 1 deletion test/cargo_build_script/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ fn test_encoded_rustflags() {
assert_eq!(flags.len(), 2);

assert!(flags[0].starts_with("--sysroot"));

// Ensure the `pwd` template has been resolved
assert!(!flags[0].contains("${pwd}"));

assert_eq!(flags[1], "--verbose");
}

fn main() {

// Perform some unit testing
test_encoded_rustflags();

Expand Down

0 comments on commit bf48102

Please sign in to comment.