From 7fa4ffaff24a5f444b93ce09fc579d6f1ea55363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 8 Nov 2024 11:02:27 +0100 Subject: [PATCH] Use std::path::MAIN_SEPARATOR to join $OUT_DIR/lib$prefix.a on Win32 to fix builds where $PWD is a \?\ path Closes: #71 Backported-from: 35a9ac6a7ba254ab706b6a053a35600fc8aed748 --- src/windows_msvc.rs | 4 ++-- src/windows_not_msvc.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/windows_msvc.rs b/src/windows_msvc.rs index 669f1c8..58f9325 100644 --- a/src/windows_msvc.rs +++ b/src/windows_msvc.rs @@ -1,6 +1,6 @@ +use std::path::{PathBuf, Path, MAIN_SEPARATOR}; use std::sync::atomic::Ordering::SeqCst; use std::sync::atomic::AtomicBool; -use std::path::{PathBuf, Path}; use self::super::apply_macros; use std::process::Command; use vswhom::VsFindResult; @@ -26,7 +26,7 @@ impl ResourceCompiler { } pub fn compile_resource, Mi: IntoIterator>(&self, out_dir: &str, prefix: &str, resource: &str, macros: Mi) -> String { - let out_file = format!("{}/{}.lib", out_dir, prefix); + let out_file = format!("{}{}{}.lib", out_dir, MAIN_SEPARATOR, prefix); // `.res`es are linkable under MSVC as well as normal libraries. if !apply_macros(Command::new(find_windows_sdk_tool_impl("rc.exe").as_ref().map_or(Path::new("rc.exe"), Path::new)) .args(&["/fo", &out_file, "/I", out_dir]), diff --git a/src/windows_not_msvc.rs b/src/windows_not_msvc.rs index 6fb713b..4d08280 100644 --- a/src/windows_not_msvc.rs +++ b/src/windows_not_msvc.rs @@ -1,6 +1,6 @@ +use std::path::{PathBuf, MAIN_SEPARATOR}; use self::super::apply_macros; use std::process::Command; -use std::path::PathBuf; use std::borrow::Cow; use std::ffi::OsStr; use std::env; @@ -22,7 +22,7 @@ impl ResourceCompiler { } pub fn compile_resource, Mi: IntoIterator>(&self, out_dir: &str, prefix: &str, resource: &str, macros: Mi) -> String { - let out_file = format!("{}/lib{}.a", out_dir, prefix); + let out_file = format!("{}{}lib{}.a", out_dir, MAIN_SEPARATOR, prefix); // Under some msys2 environments, $MINGW_CHOST has the correct target for // GNU windres or llvm-windres (clang32, clang64, or clangarm64)