Skip to content

Commit

Permalink
Fix MSVC Host Cross Compilation (#218)
Browse files Browse the repository at this point in the history
* Replace \ with / in prefix on msvc

* Run cargo fmt

* Add comment for path seperator replacement
  • Loading branch information
nathaniel-daniel authored Nov 30, 2023
1 parent 2b0e2b1 commit 86ad505
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ impl Build {
// Change the install directory to happen inside of the build directory.
if host.contains("pc-windows-gnu") {
configure.arg(&format!("--prefix={}", sanitize_sh(&install_dir)));
} else if host.contains("pc-windows-msvc") {
// On Windows, the prefix argument does not support \ path seperators
// when cross compiling.
// Always use / as a path seperator instead of \, since that works for both
// native and cross builds.
configure.arg(&format!(
"--prefix={}",
install_dir.to_str().unwrap().replace("\\", "/")
));
} else {
configure.arg(&format!("--prefix={}", install_dir.display()));
}
Expand Down

0 comments on commit 86ad505

Please sign in to comment.