diff --git a/src/tools/run-make-support/src/external_deps/cygpath.rs b/src/tools/run-make-support/src/external_deps/cygpath.rs index 07d8e840a63a8..cd01ecf28dab8 100644 --- a/src/tools/run-make-support/src/external_deps/cygpath.rs +++ b/src/tools/run-make-support/src/external_deps/cygpath.rs @@ -1,8 +1,6 @@ -use std::panic; use std::path::Path; use crate::command::Command; -use crate::util::handle_failed_output; /// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is /// available on the platform! @@ -22,14 +20,19 @@ use crate::util::handle_failed_output; #[track_caller] #[must_use] pub fn get_windows_path>(path: P) -> String { - let caller = panic::Location::caller(); - let mut cygpath = Command::new("cygpath"); - cygpath.arg("-w"); - cygpath.arg(path.as_ref()); - let output = cygpath.run(); - if !output.status().success() { - handle_failed_output(&cygpath, output, caller.line()); + // If the path looks unixy then use cygpath otherwise return it unchanged. + // If cygpath fails then fallback to just using the path as given. + if path.as_ref().starts_with("/") { + let mut cygpath = Command::new("cygpath"); + cygpath.arg("-w"); + cygpath.arg(path.as_ref()); + let output = cygpath.run(); + if !output.status().success() { + return path.as_ref().to_str().unwrap().into(); + } + // cygpath -w can attach a newline + output.stdout_utf8().trim().to_string() + } else { + path.as_ref().to_str().unwrap().into() } - // cygpath -w can attach a newline - output.stdout_utf8().trim().to_string() }