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: 1 addition & 1 deletion tools/upstream_wrapper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ ALL_TOOLS = [target for target in TOOLS.values()]
data = ALL_TOOLS if tool_name == "cargo" else [target],
edition = "2018",
rustc_env = {
"WRAPPED_TOOL_EXECPATH": "$(execpath {})".format(target),
"WRAPPED_TOOL_NAME": tool_name,
"WRAPPED_TOOL_ROOTPATH": "$(rootpath {})".format(target),
"WRAPPED_TOOL_TARGET": "$(rlocationpath {})".format(target),
},
toolchains = ["//rust/toolchain:current_rust_toolchain"],
Expand Down
10 changes: 7 additions & 3 deletions tools/upstream_wrapper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::{exit, Command};

const WRAPPED_TOOL_NAME: &str = env!("WRAPPED_TOOL_NAME");
const WRAPPED_TOOL_TARGET: &str = env!("WRAPPED_TOOL_TARGET");
const WRAPPED_TOOL_EXECPATH: &str = env!("WRAPPED_TOOL_EXECPATH");
const WRAPPED_TOOL_ROOTPATH: &str = env!("WRAPPED_TOOL_ROOTPATH");

#[cfg(not(target_os = "windows"))]
const PATH_SEPARATOR: &str = ":";
Expand All @@ -20,7 +20,11 @@ fn main() {
}
Ok(path)
})
.unwrap_or(PathBuf::from(WRAPPED_TOOL_EXECPATH));
.unwrap_or_else(|_| {
std::env::current_dir()
.expect("Failed to get current directory")
.join(WRAPPED_TOOL_ROOTPATH)
});

if !wrapped_tool_path.exists() {
panic!(
Expand All @@ -39,7 +43,7 @@ fn main() {

let working_directory = std::env::var_os("BUILD_WORKING_DIRECTORY")
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().expect("Failed to get working directory"));
.unwrap_or_else(|| std::env::current_dir().expect("Failed to get build working directory"));

let mut command = Command::new(wrapped_tool_path);
command
Expand Down