Skip to content

Commit 52feb40

Browse files
[3844] Use rootpath for wrapper root for determinism (#3845)
Fixes #3844 Uses a relative path instead of absolute: ``` WRAPPED_TOOL_EXECPATH: ../+rust+rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/bin/cargo ``` --------- Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
1 parent f197ab8 commit 52feb40

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

tools/upstream_wrapper/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ ALL_TOOLS = [target for target in TOOLS.values()]
2121
data = ALL_TOOLS if tool_name == "cargo" else [target],
2222
edition = "2018",
2323
rustc_env = {
24-
"WRAPPED_TOOL_EXECPATH": "$(execpath {})".format(target),
2524
"WRAPPED_TOOL_NAME": tool_name,
25+
"WRAPPED_TOOL_ROOTPATH": "$(rootpath {})".format(target),
2626
"WRAPPED_TOOL_TARGET": "$(rlocationpath {})".format(target),
2727
},
2828
toolchains = ["//rust/toolchain:current_rust_toolchain"],

tools/upstream_wrapper/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::process::{exit, Command};
44

55
const WRAPPED_TOOL_NAME: &str = env!("WRAPPED_TOOL_NAME");
66
const WRAPPED_TOOL_TARGET: &str = env!("WRAPPED_TOOL_TARGET");
7-
const WRAPPED_TOOL_EXECPATH: &str = env!("WRAPPED_TOOL_EXECPATH");
7+
const WRAPPED_TOOL_ROOTPATH: &str = env!("WRAPPED_TOOL_ROOTPATH");
88

99
#[cfg(not(target_os = "windows"))]
1010
const PATH_SEPARATOR: &str = ":";
@@ -20,7 +20,11 @@ fn main() {
2020
}
2121
Ok(path)
2222
})
23-
.unwrap_or(PathBuf::from(WRAPPED_TOOL_EXECPATH));
23+
.unwrap_or_else(|_| {
24+
std::env::current_dir()
25+
.expect("Failed to get current directory")
26+
.join(WRAPPED_TOOL_ROOTPATH)
27+
});
2428

2529
if !wrapped_tool_path.exists() {
2630
panic!(
@@ -39,7 +43,7 @@ fn main() {
3943

4044
let working_directory = std::env::var_os("BUILD_WORKING_DIRECTORY")
4145
.map(PathBuf::from)
42-
.unwrap_or_else(|| std::env::current_dir().expect("Failed to get working directory"));
46+
.unwrap_or_else(|| std::env::current_dir().expect("Failed to get build working directory"));
4347

4448
let mut command = Command::new(wrapped_tool_path);
4549
command

0 commit comments

Comments
 (0)