Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sdl2-sys to build for windows-gnu target #763

Merged
merged 1 commit into from
Mar 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions sdl2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ fn download_sdl2() -> PathBuf {

// compile a shared or static lib depending on the feature
#[cfg(feature = "bundled")]
fn compile_sdl2(sdl2_build_path: &Path) -> PathBuf {
let install_path = if cfg!(feature = "static-link") {
cmake::Config::new(sdl2_build_path)
.define("SDL_SHARED", "OFF")
.define("SDL_STATIC", "ON")
.build()
fn compile_sdl2(sdl2_build_path: &Path, target_os: &str) -> PathBuf {
let mut cfg = cmake::Config::new(sdl2_build_path);

if target_os == "windows-gnu" {
cfg.define("VIDEO_OPENGLES", "OFF");
}

if cfg!(feature = "static-link") {
cfg.define("SDL_SHARED", "OFF");
cfg.define("SDL_STATIC", "ON");
} else {
cmake::Config::new(sdl2_build_path)
.define("SDL_SHARED", "ON")
.define("SDL_STATIC", "OFF")
.build()
};
cfg.define("SDL_SHARED", "ON");
cfg.define("SDL_STATIC", "OFF");
}

install_path
cfg.build()
}

#[cfg(not(feature = "bundled"))]
Expand Down Expand Up @@ -168,7 +170,7 @@ fn link_sdl2(target_os: &str) {
}

// Also linked to any required libraries for each supported platform
if target_os == "windows-msvc" {
if target_os.contains("windows") {
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=gdi32");
println!("cargo:rustc-link-lib=winmm");
Expand Down Expand Up @@ -203,7 +205,7 @@ fn main() {

#[cfg(feature = "bundled")] {
let sdl2_source_path = download_sdl2();
let sdl2_compiled_path = compile_sdl2(sdl2_source_path.as_path());
let sdl2_compiled_path = compile_sdl2(sdl2_source_path.as_path(), target_os);

let sdl2_downloaded_include_path = sdl2_source_path.join("include");
let sdl2_compiled_lib_path = sdl2_compiled_path.join("lib");
Expand Down