Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions cargo/private/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ def _cargo_build_script_impl(ctx):
env["CARGO_ENCODED_RUSTFLAGS"] = "\\x1f".join([
# Allow build scripts to locate the generated sysroot
"--sysroot=${{pwd}}/{}".format(toolchain.sysroot),
# Keep build scripts from baking the exec root into their output
"--remap-path-prefix=${pwd}=.",
Comment thread
UebelAndre marked this conversation as resolved.
] + ctx.attr.rustc_flags)

for f in ctx.attr.crate_features:
Expand Down
7 changes: 5 additions & 2 deletions cargo/tests/cargo_build_script/tools_exec/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ fn test_encoded_rustflags() {
.split('\x1f')
.map(str::to_string)
.collect();
assert_eq!(flags.len(), 2);
assert_eq!(flags.len(), 3);

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

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

assert_eq!(flags[1], "--cfg=foo=\"bar\"");
assert!(flags[1].starts_with("--remap-path-prefix"));
assert!(!flags[1].contains("${pwd}"));

assert_eq!(flags[2], "--cfg=foo=\"bar\"");
}

/// Ensure Make variables provided by the `toolchains` attribute are expandable.
Expand Down
Loading