Skip to content

Commit 9bf061b

Browse files
committed
use static linking on windows/emscripten
1 parent d9230fe commit 9bf061b

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

projectm-sys/build.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,32 @@ fn main() {
7171
// Determine the library name based on the build profile
7272
let profile = env::var("PROFILE").unwrap_or_else(|_| "release".to_string());
7373

74-
// Platform-independent library linking
75-
if profile == "release" {
76-
println!("cargo:rustc-link-lib=dylib=projectM-4");
77-
if cfg!(feature = "playlist") {
78-
println!("cargo:rustc-link-lib=dylib=projectM-4-playlist");
74+
// Platform-specific library linking
75+
if cfg!(target_os = "windows") || cfg!(target_os = "emscripten") {
76+
// Use static linking for Windows and Emscripten
77+
if profile == "release" {
78+
println!("cargo:rustc-link-lib=static=projectM-4");
79+
if cfg!(feature = "playlist") {
80+
println!("cargo:rustc-link-lib=static=projectM-4-playlist");
81+
}
82+
} else {
83+
println!("cargo:rustc-link-lib=static=projectM-4d");
84+
if cfg!(feature = "playlist") {
85+
println!("cargo:rustc-link-lib=static=projectM-4-playlistd");
86+
}
7987
}
8088
} else {
81-
println!("cargo:rustc-link-lib=dylib=projectM-4d");
82-
if cfg!(feature = "playlist") {
83-
println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd");
89+
// Use dynamic linking for other platforms (Linux, macOS)
90+
if profile == "release" {
91+
println!("cargo:rustc-link-lib=dylib=projectM-4");
92+
if cfg!(feature = "playlist") {
93+
println!("cargo:rustc-link-lib=dylib=projectM-4-playlist");
94+
}
95+
} else {
96+
println!("cargo:rustc-link-lib=dylib=projectM-4d");
97+
if cfg!(feature = "playlist") {
98+
println!("cargo:rustc-link-lib=dylib=projectM-4-playlistd");
99+
}
84100
}
85101
}
86102

0 commit comments

Comments
 (0)