Skip to content

Commit 0e2ebff

Browse files
committedFeb 29, 2024
Specify PATH for executables on Windows
1 parent 91a2e57 commit 0e2ebff

File tree

1 file changed

+13
-6
lines changed
  • src/tools/run-make-support/src

1 file changed

+13
-6
lines changed
 

‎src/tools/run-make-support/src/lib.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ impl AuxBuildInvocationBuilder {
8989
}
9090

9191
fn run_common(bin_name: &str) -> (Command, Output) {
92-
let bin_name = if std::env::var("TARGET").unwrap().contains("windows") {
93-
format!("{}.exe", bin_name)
94-
} else {
95-
bin_name.to_owned()
96-
};
92+
let target = std::env::var("TARGET").unwrap();
93+
94+
let bin_name =
95+
if target.contains("windows") { format!("{}.exe", bin_name) } else { bin_name.to_owned() };
9796

9897
let mut bin_path = PathBuf::new();
9998
bin_path.push(std::env::var("TMPDIR").unwrap());
@@ -104,11 +103,19 @@ fn run_common(bin_name: &str) -> (Command, Output) {
104103
let mut target_rpath_env_path = String::new();
105104
target_rpath_env_path.push_str(&std::env::var("TMPDIR").unwrap());
106105
target_rpath_env_path.push(':');
107-
target_rpath_env_path.push_str(&std::env::var("TARGET_RPATH_DIR").unwrap());
106+
target_rpath_env_path.push_str(&std::env::var("TARGET_RPATH_ENV").unwrap());
108107
target_rpath_env_path.push(':');
109108
target_rpath_env_path.push_str(&std::env::var(&ld_lib_path_envvar).unwrap());
110109
target_rpath_env_path
111110
});
111+
112+
if target.contains("windows") {
113+
let mut path = std::env::var("PATH").unwrap_or(String::new());
114+
path.push(':');
115+
path.push_str(&std::env::var("TARGET_RPATH_DIR").unwrap());
116+
cmd.env("PATH", &path);
117+
}
118+
112119
let output = cmd.output().unwrap();
113120
(cmd, output)
114121
}

0 commit comments

Comments
 (0)