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

Search for different versions of libwayland #2336

Merged
merged 1 commit into from
Dec 30, 2021
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
14 changes: 12 additions & 2 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,30 @@ fn open_x_display() -> Option<(ptr::NonNull<raw::c_void>, libloading::Library)>
}
}

unsafe fn find_library(paths: &[&str]) -> Option<libloading::Library> {
for path in paths {
match libloading::Library::new(path) {
Ok(lib) => return Some(lib),
_ => continue,
};
}
None
}

fn test_wayland_display() -> Option<libloading::Library> {
/* We try to connect and disconnect here to simply ensure there
* is an active wayland display available.
*/
log::info!("Loading Wayland library to get the current display");
let library = unsafe {
let client_library = libloading::Library::new("libwayland-client.so").ok()?;
let client_library = find_library(&["libwayland-client.so.0", "libwayland-client.so"])?;
let wl_display_connect: libloading::Symbol<WlDisplayConnectFun> =
client_library.get(b"wl_display_connect").unwrap();
let wl_display_disconnect: libloading::Symbol<WlDisplayDisconnectFun> =
client_library.get(b"wl_display_disconnect").unwrap();
let display = ptr::NonNull::new(wl_display_connect(ptr::null()))?;
wl_display_disconnect(display.as_ptr());
libloading::Library::new("libwayland-egl.so").ok()?
find_library(&["libwayland-egl.so.1", "libwayland-egl.so"])?
};
Some(library)
}
Expand Down