From bf4810257ea982a1593e6fd2269c1f6d98e01ca2 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Fri, 4 Mar 2022 09:06:12 -0800 Subject: [PATCH] Fixed unresolved `pwd` template --- cargo/cargo_build_script_runner/bin.rs | 19 ++++++++++--------- test/cargo_build_script/build.rs | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cargo/cargo_build_script_runner/bin.rs b/cargo/cargo_build_script_runner/bin.rs index 5f43f27983..c806dc38c9 100644 --- a/cargo/cargo_build_script_runner/bin.rs +++ b/cargo/cargo_build_script_runner/bin.rs @@ -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 @@ -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!( diff --git a/test/cargo_build_script/build.rs b/test/cargo_build_script/build.rs index 17407f3bb3..12d1b53d6e 100644 --- a/test/cargo_build_script/build.rs +++ b/test/cargo_build_script/build.rs @@ -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();