mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Use StaticStructGenerator on Windows
This commit is contained in:
parent
0d96bbde4b
commit
3650f356d1
2 changed files with 12 additions and 42 deletions
|
@ -15,16 +15,19 @@ fn main() {
|
||||||
// For now, we only support EGL, and only on Windows and Android.
|
// For now, we only support EGL, and only on Windows and Android.
|
||||||
if target.contains("android") || target.contains("windows") {
|
if target.contains("android") || target.contains("windows") {
|
||||||
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
|
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
|
||||||
if target.contains("android") {
|
Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [])
|
||||||
Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [])
|
.write_bindings(gl_generator::StaticStructGenerator, &mut file)
|
||||||
.write_bindings(gl_generator::StaticStructGenerator, &mut file)
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
}
|
// Historically, Android builds have succeeded with rust-link-lib=EGL.
|
||||||
|
// On Windows when relying on %LIBS% to contain libEGL.lib, however,
|
||||||
|
// we must explicitly use rustc-link-lib=libEGL or rustc will attempt
|
||||||
|
// to link EGL.lib instead.
|
||||||
if target.contains("windows") {
|
if target.contains("windows") {
|
||||||
Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [])
|
println!("cargo:rustc-link-lib=libEGL");
|
||||||
.write_bindings(gl_generator::StructGenerator, &mut file)
|
} else {
|
||||||
.unwrap();
|
println!("cargo:rust-link-lib=EGL");
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.contains("linux") ||
|
if target.contains("linux") ||
|
||||||
|
|
|
@ -11,20 +11,9 @@ pub type ServoGl = std::rc::Rc<dyn servo::gl::Gl>;
|
||||||
pub mod egl {
|
pub mod egl {
|
||||||
use servo::gl::GlesFns;
|
use servo::gl::GlesFns;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use winapi::um::libloaderapi::{GetProcAddress, LoadLibraryA};
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
pub type EGLNativeWindowType = winapi::shared::windef::HWND;
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
pub type EGLNativeWindowType = *const libc::c_void;
|
pub type EGLNativeWindowType = *const libc::c_void;
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
pub type EGLNativeWindowType = *const libc::c_void;
|
|
||||||
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
|
|
||||||
pub type EGLNativeWindowType = *const libc::c_void;
|
|
||||||
|
|
||||||
pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
|
pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
|
||||||
pub type khronos_uint64_t = libc::uint64_t;
|
pub type khronos_uint64_t = libc::uint64_t;
|
||||||
pub type khronos_ssize_t = libc::c_long;
|
pub type khronos_ssize_t = libc::c_long;
|
||||||
|
@ -37,7 +26,6 @@ pub mod egl {
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
pub fn init() -> Result<crate::gl_glue::ServoGl, &'static str> {
|
pub fn init() -> Result<crate::gl_glue::ServoGl, &'static str> {
|
||||||
info!("Loading EGL...");
|
info!("Loading EGL...");
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -54,27 +42,6 @@ pub mod egl {
|
||||||
Ok(egl)
|
Ok(egl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
pub fn init() -> Result<crate::gl_glue::ServoGl, &'static str> {
|
|
||||||
info!("Loading EGL...");
|
|
||||||
|
|
||||||
let dll = b"libEGL.dll\0" as &[u8];
|
|
||||||
let dll = unsafe { LoadLibraryA(dll.as_ptr() as *const _) };
|
|
||||||
if dll.is_null() {
|
|
||||||
Err("Can't find libEGL.dll")
|
|
||||||
} else {
|
|
||||||
unsafe {
|
|
||||||
let egl = GlesFns::load_with(|addr| {
|
|
||||||
let addr = CString::new(addr.as_bytes()).unwrap();
|
|
||||||
let addr = addr.as_ptr();
|
|
||||||
GetProcAddress(dll, addr) as *const _
|
|
||||||
});
|
|
||||||
info!("EGL loaded");
|
|
||||||
Ok(egl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue