From 7f6f4f8d04b9f6dfbbc9528552fa45db932d6dae Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 24 Dec 2014 08:09:16 +0100 Subject: [PATCH] Update for gl_generator's changes --- Cargo.toml | 5 +-- build.rs | 68 +++++++++++++++++++++++++++++++++++++++++ examples/support/mod.rs | 14 ++------- src/android/ffi.rs | 7 +---- src/win32/gl.rs | 18 ++--------- src/x11/ffi.rs | 17 ++--------- tests/headless.rs | 7 +---- 7 files changed, 79 insertions(+), 57 deletions(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 785d1701..99a727bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,16 +9,17 @@ license = "Apache-2.0" readme = "README.md" repository = "https://github.com/tomaka/glutin" documentation = "http://tomaka.github.io/glutin/" +build = "build.rs" [features] default = ["window"] window = [] headless = [] -[dependencies.gl_generator] +[dependencies.gl_common] git = "https://github.com/bjz/gl-rs" -[dependencies.gl_common] +[build-dependencies.gl_generator] git = "https://github.com/bjz/gl-rs" [target.arm-linux-androideabi.dependencies.android_glue] diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..166c223e --- /dev/null +++ b/build.rs @@ -0,0 +1,68 @@ +extern crate gl_generator; +extern crate khronos_api; + +use std::os; +use std::io::File; + +fn main() { + let target = os::getenv("TARGET").unwrap(); + let dest = Path::new(os::getenv("OUT_DIR").unwrap()); + + if target.contains("windows") { + let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StaticGenerator, + gl_generator::registry::Ns::Wgl, + khronos_api::WGL_XML, vec![], + "1.0", "core", &mut file).unwrap(); + + let mut file = File::create(&dest.join("wgl_extra_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StructGenerator, + gl_generator::registry::Ns::Wgl, + khronos_api::WGL_XML, + vec![ + "WGL_ARB_create_context".to_string(), + "WGL_EXT_swap_control".to_string() + ], + "1.0", "core", &mut file).unwrap(); + } + + if target.contains("linux") { + let mut file = File::create(&dest.join("glx_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StaticGenerator, + gl_generator::registry::Ns::Glx, + khronos_api::GLX_XML, vec![], + "1.4", "core", &mut file).unwrap(); + + let mut file = File::create(&dest.join("glx_extra_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StructGenerator, + gl_generator::registry::Ns::Glx, + khronos_api::GLX_XML, + vec![ + "GLX_ARB_create_context".to_string(), + ], + "1.4", "core", &mut file).unwrap(); + } + + if target.contains("android") { + let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StaticGenerator, + gl_generator::registry::Ns::Egl, + khronos_api::EGL_XML, vec![], + "1.5", "core", &mut file).unwrap(); + } + + + // TODO: only build the bindings below if we run tests/examples + + let mut file = File::create(&dest.join("test_gl_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StructGenerator, + gl_generator::registry::Ns::Gl, + khronos_api::GL_XML, vec![], + "1.1", "core", &mut file).unwrap(); + + let mut file = File::create(&dest.join("test_gles1_bindings.rs")).unwrap(); + gl_generator::generate_bindings(gl_generator::StructGenerator, + gl_generator::registry::Ns::Gles1, + khronos_api::GL_XML, vec![], + "1.1", "core", &mut file).unwrap(); +} diff --git a/examples/support/mod.rs b/examples/support/mod.rs index eb27d236..69046532 100644 --- a/examples/support/mod.rs +++ b/examples/support/mod.rs @@ -7,23 +7,13 @@ use glutin; #[cfg(not(target_os = "android"))] mod gl { - generate_gl_bindings! { - api: "gl", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); } #[cfg(target_os = "android")] mod gl { pub use self::Gles1 as Gl; - generate_gl_bindings! { - api: "gles1", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gles1_bindings.rs")); } pub struct Context { diff --git a/src/android/ffi.rs b/src/android/ffi.rs index 5e7060d7..111f6707 100644 --- a/src/android/ffi.rs +++ b/src/android/ffi.rs @@ -17,12 +17,7 @@ pub mod egl { pub type NativePixmapType = super::EGLNativePixmapType; pub type NativeWindowType = super::EGLNativeWindowType; - generate_gl_bindings! { - api: "egl", - profile: "core", - version: "1.5", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs")); } pub type khronos_utime_nanoseconds_t = khronos_uint64_t; diff --git a/src/win32/gl.rs b/src/win32/gl.rs index a44af77b..1354d954 100644 --- a/src/win32/gl.rs +++ b/src/win32/gl.rs @@ -1,25 +1,11 @@ /// WGL bindings pub mod wgl { - generate_gl_bindings! { - api: "wgl", - profile: "core", - version: "1.0", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/wgl_bindings.rs")); } /// Functions that are not necessarly always available pub mod wgl_extra { - generate_gl_bindings! { - api: "wgl", - profile: "core", - version: "1.0", - generator: "struct", - extensions: [ - "WGL_ARB_create_context", - "WGL_EXT_swap_control" - ] - } + include!(concat!(env!("OUT_DIR"), "/wgl_extra_bindings.rs")); } #[link(name = "opengl32")] diff --git a/src/x11/ffi.rs b/src/x11/ffi.rs index 1f8b10f5..5610eee0 100644 --- a/src/x11/ffi.rs +++ b/src/x11/ffi.rs @@ -8,25 +8,12 @@ use libc; /// GLX bindings pub mod glx { - generate_gl_bindings! { - api: "glx", - profile: "core", - version: "1.4", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/glx_bindings.rs")); } /// Functions that are not necessarly always available pub mod glx_extra { - generate_gl_bindings! { - api: "glx", - profile: "core", - version: "1.4", - generator: "struct", - extensions: [ - "GLX_ARB_create_context" - ] - } + include!(concat!(env!("OUT_DIR"), "/glx_extra_bindings.rs")); } pub type Atom = libc::c_ulong; diff --git a/tests/headless.rs b/tests/headless.rs index ca96fdb7..b2b23da4 100644 --- a/tests/headless.rs +++ b/tests/headless.rs @@ -6,12 +6,7 @@ extern crate glutin; extern crate libc; mod gl { - generate_gl_bindings! { - api: "gl", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); } #[cfg(feature = "headless")]