From 2105c660c7ee38e23c4e7fa162464b726bec623a Mon Sep 17 00:00:00 2001 From: Ali Somay Date: Thu, 28 Nov 2024 18:10:21 +0100 Subject: [PATCH] Bump version --- Cargo.toml | 2 +- build.rs | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fcf2c88..abb1ace 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libpd-sys" -version = "0.3.3" +version = "0.3.4" authors = ["alisomay "] edition = "2021" license = "BSD-3-Clause" diff --git a/build.rs b/build.rs index 8f318d8..43cb0b9 100644 --- a/build.rs +++ b/build.rs @@ -63,11 +63,12 @@ fn main() { #[cfg(target_os = "windows")] { + // Determine the appropriate CRT linkage let profile = std::env::var("PROFILE").unwrap(); - let crt_linkage = if profile == "release" { - "MultiThreadedDLL" + let msvc_runtime_flag = if profile == "release" { + "/MD" // Multithreaded DLL } else { - "MultiThreadedDebugDLL" + "/MDd" // Multithreaded Debug DLL }; // For windows we need to link pthread. @@ -75,13 +76,14 @@ fn main() { // Mingw support is not tested yet but should work. let pthread_root = project_dir.join("pthreads"); + let compiler = target_info.compiler.unwrap(); let (pthread_lib_root, pthread_lib_path, pthread_lib_name, pthread_include): ( PathBuf, PathBuf, &str, PathBuf, ) = match &*target_info.arch { - "x86_64" => match &*(target_info.compiler.unwrap()) { + "x86_64" => match compiler.as_str() { "msvc" => { let lib_root = pthread_root .join("msvc") @@ -140,7 +142,9 @@ fn main() { _ => panic!("Unsupported architecture: {}", target_info.arch), }; - let lib_destination = Config::new("libpd") + let mut lib_destination = Config::new("libpd"); + + lib_destination .define("PD_LOCALE", PD_LOCALE) .define("PD_MULTI", PD_MULTI) .define("PD_UTILS", PD_UTILS) @@ -148,15 +152,19 @@ fn main() { .define("LIBPD_RS_EXTRA", LIBPD_RS_EXTRA) .define("PTHREADS_LIB", pthread_lib_path.to_str().unwrap()) .define("PTHREADS_INCLUDE_DIR", pthread_include.to_str().unwrap()) - .define("CMAKE_MSVC_RUNTIME_LIBRARY", crt_linkage) .cflag(format!("-DWISH={}", WISH)) .cflag(format!("-I{}", libpd_wrapper_dir.to_str().unwrap())) .cflag(format!("-I{}", pd_source.to_str().unwrap())) .cflag(format!("-DPD_FLOATSIZE={PD_FLOATSIZE}")) .no_build_target(true) .always_configure(true) - .very_verbose(true) - .build(); + .very_verbose(true); + + if compiler.as_str() == "msvc" { + lib_destination.cflag(msvc_runtime_flag); + } + + let lib_destination = lib_destination.build(); let library_root = lib_destination.join("build/libs");