diff --git a/examples/nim_timer/rust_bindings/build.rs b/examples/nim_timer/rust_bindings/build.rs index b5b12a8..a6f0fd8 100644 --- a/examples/nim_timer/rust_bindings/build.rs +++ b/examples/nim_timer/rust_bindings/build.rs @@ -21,12 +21,18 @@ fn main() { } } + // Match the per-OS shared-library naming used by the CMakeLists: + // macOS: lib.dylib + // Linux: lib.so + // Windows: .dll (Cargo links the auto-generated .lib import lib) #[cfg(target_os = "macos")] - let lib_ext = "dylib"; + let out_lib = repo_root.join("libnimtimer.dylib"); #[cfg(target_os = "linux")] - let lib_ext = "so"; - - let out_lib = repo_root.join(format!("libnimtimer.{lib_ext}")); + let out_lib = repo_root.join("libnimtimer.so"); + #[cfg(target_os = "windows")] + let out_lib = repo_root.join("nimtimer.dll"); + #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] + compile_error!("nim-ffi build.rs: unsupported target OS (expected macos, linux, or windows)"); let mut cmd = Command::new("nim"); cmd.arg("c") diff --git a/ffi/codegen/rust.nim b/ffi/codegen/rust.nim index 5236dfc..0d59327 100644 --- a/ffi/codegen/rust.nim +++ b/ffi/codegen/rust.nim @@ -109,12 +109,18 @@ fn main() { } } + // Match the per-OS shared-library naming used by the CMakeLists: + // macOS: lib.dylib + // Linux: lib.so + // Windows: .dll (Cargo links the auto-generated .lib import lib) #[cfg(target_os = "macos")] - let lib_ext = "dylib"; + let out_lib = repo_root.join("lib$2.dylib"); #[cfg(target_os = "linux")] - let lib_ext = "so"; - - let out_lib = repo_root.join(format!("lib$2.{lib_ext}")); + let out_lib = repo_root.join("lib$2.so"); + #[cfg(target_os = "windows")] + let out_lib = repo_root.join("$2.dll"); + #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] + compile_error!("nim-ffi build.rs: unsupported target OS (expected macos, linux, or windows)"); let mut cmd = Command::new("nim"); cmd.arg("c")