Skip to content

Commit

Permalink
Conditionally link release/debug libs
Browse files Browse the repository at this point in the history
  • Loading branch information
bgourlie committed Jun 10, 2018
1 parent 89a7ee2 commit affbea4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sdl2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn compute_include_paths() -> Vec<String> {
include_paths
}

fn link_sdl2(target_os: &str) {
fn link_sdl2(target_os: &str, profile: &str) {
#[cfg(all(feature = "use-pkgconfig", not(feature = "bundled")))] {
// prints the appropriate linking parameters when using pkg-config
// useless when using "bundled"
Expand Down Expand Up @@ -184,9 +184,14 @@ fn link_sdl2(target_os: &str) {
}

#[cfg(feature = "static-link")] {
if cfg!(feature = "bundled") || cfg!(feature = "use-pkgconfig") == false {
println!("cargo:rustc-link-lib=static=SDL2maind");
println!("cargo:rustc-link-lib=static=SDL2d");
if cfg!(feature = "bundled") || cfg!(feature = "use-pkgconfig") == false {
if profile.contains("release") {
println!("cargo:rustc-link-lib=static=SDL2main");
println!("cargo:rustc-link-lib=static=SDL2");
} else {
println!("cargo:rustc-link-lib=static=SDL2maind");
println!("cargo:rustc-link-lib=static=SDL2d");
}
}

// Also linked to any required libraries for each supported platform
Expand Down Expand Up @@ -282,6 +287,7 @@ fn link_sdl2(target_os: &str) {
fn main() {
let target = env::var("TARGET").expect("Cargo build scripts always have TARGET");
let host = env::var("HOST").expect("Cargo build scripts always have HOST");
let profile = env::var("PROFILE").expect("Cargo build scripts always have PROFILE");
let target_os = get_os_from_triple(target.as_str()).unwrap();

#[cfg(feature = "bundled")] {
Expand All @@ -308,7 +314,7 @@ fn main() {
copy_pregenerated_bindings();
}

link_sdl2(target_os);
link_sdl2(target_os, profile.as_str());
}

#[cfg(not(feature = "bindgen"))]
Expand Down

0 comments on commit affbea4

Please sign in to comment.