Generate (e)gl_bindings based on feature set

This commit is contained in:
Victor Brekenfeld 2018-11-21 09:28:15 +01:00
parent ac0dc42e9e
commit 09e589b23c
2 changed files with 42 additions and 36 deletions

View File

@ -34,16 +34,18 @@ error-chain = "0.11.0"
lazy_static = "1.0.0" lazy_static = "1.0.0"
[build-dependencies] [build-dependencies]
gl_generator = "0.9" gl_generator = { version = "0.9", optional = true }
[features] [features]
default = ["backend_winit", "backend_drm", "backend_libinput", "backend_udev", "renderer_glium", "xwayland"] default = ["backend_winit", "backend_drm", "backend_libinput", "backend_udev", "renderer_glium", "xwayland"]
backend_winit = ["winit", "wayland-server/dlopen", "wayland-client/dlopen"] backend_winit = ["winit", "wayland-server/dlopen", "wayland-client/dlopen", "backend_egl"]
backend_drm = ["drm", "gbm"] backend_drm = ["drm", "backend_egl"]
backend_egl = ["gl_generator"]
backend_libinput = ["input"] backend_libinput = ["input"]
backend_session = [] backend_session = []
backend_session_udev = ["udev", "backend_session"] backend_session_udev = ["udev", "backend_session"]
backend_session_logind = ["dbus", "systemd", "backend_session"] backend_session_logind = ["dbus", "systemd", "backend_session"]
backend_udev = ["udev", "backend_drm", "backend_session_udev"] backend_udev = ["udev", "backend_drm", "backend_session_udev"]
renderer_glium = ["glium"] renderer_gl = ["gl_generator"]
renderer_glium = ["renderer_gl", "glium"]
xwayland = [] xwayland = []

View File

@ -8,6 +8,7 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
if env::var_os("CARGO_FEATURE_BACKEND_EGL").is_some() {
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap(); let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
Registry::new( Registry::new(
Api::Egl, Api::Egl,
@ -31,7 +32,9 @@ fn main() {
], ],
).write_bindings(gl_generator::GlobalGenerator, &mut file) ).write_bindings(gl_generator::GlobalGenerator, &mut file)
.unwrap(); .unwrap();
}
if env::var_os("CARGO_FEATURE_RENDERER_GL").is_some() {
let mut file = File::create(&dest.join("gl_bindings.rs")).unwrap(); let mut file = File::create(&dest.join("gl_bindings.rs")).unwrap();
Registry::new( Registry::new(
Api::Gles2, Api::Gles2,
@ -39,6 +42,7 @@ fn main() {
Profile::Compatibility, Profile::Compatibility,
Fallbacks::None, Fallbacks::None,
["GL_OES_EGL_image"], ["GL_OES_EGL_image"],
).write_bindings(gl_generator::GlobalGenerator, &mut file) ).write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap(); .unwrap();
} }
}