From 6e82505e229b4cfa351abd70ba67b7b12036edf8 Mon Sep 17 00:00:00 2001 From: Aaron Cottle Date: Tue, 2 Sep 2025 17:20:02 +1000 Subject: [PATCH] Support cross compiling from linux to x86_64-pc-windows-gnu, update bindgen and suppress spurious warning generated by bindgen --- Cargo.toml | 2 +- build.rs | 16 ++++++++++++++-- src/lib.rs | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index abb1ace..35fe659 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,4 @@ exclude = [ [build-dependencies] cmake = "0.1.50" -bindgen = "0.69.1" +bindgen = "0.72.1" diff --git a/build.rs b/build.rs index 8ccda2f..4c3f6dc 100644 --- a/build.rs +++ b/build.rs @@ -212,10 +212,22 @@ fn main() { let library_root = lib_destination.join("build/libs"); println!("cargo:rustc-link-search={}", library_root.to_string_lossy()); + // the target operating system (NOT the same as cfg(target_os) + // since in a build.rs, this will always be the host system. + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + if !matches!(PD_MULTI, "true") { - println!("cargo:rustc-link-lib=static=pd"); + if target_os == "windows" { + println!("cargo:rustc-link-lib=static=libpd-static"); + } else { + println!("cargo:rustc-link-lib=static=pd"); + } } else { - println!("cargo:rustc-link-lib=static=pd-multi"); + if target_os == "windows" { + println!("cargo:rustc-link-lib=static=libpd-multi-static"); + } else { + println!("cargo:rustc-link-lib=static=pd-multi"); + } } } diff --git a/src/lib.rs b/src/lib.rs index c721f00..dce2f26 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] +#![allow(unnecessary_transmutes)] //! Rust bindings for [libpd](https://github.com/libpd/libpd). //!