Skip to content

Commit

Permalink
ohos: Only look for libEGL.so
Browse files Browse the repository at this point in the history
This avoids needless overhead and error messages in the console
when loading `libEGL.so.1` fails.
  • Loading branch information
jschwe committed Sep 5, 2024
1 parent 4108db0 commit 67a1dd4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/platform/generic/egl/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ static EGL_LIBRARY: LazyLock<EGLLibraryWrapper> = LazyLock::new(|| unsafe {
EGLLibraryWrapper(module)
});

#[cfg(target_env = "ohos")]
static EGL_POTENTIAL_SO_NAMES: [&CStr; 1] = [c"libEGL.so"];

#[cfg(not(any(target_os = "windows", target_os = "macos", target_env = "ohos")))]
static EGL_POTENTIAL_SO_NAMES: [&CStr; 2] = [c"libEGL.so.1", c"libEGL.so"];

#[cfg(not(any(target_os = "windows", target_os = "macos")))]
static EGL_LIBRARY: LazyLock<EGLLibraryWrapper> = LazyLock::new(|| {
for soname in [c"libEGL.so.1".as_ptr(), c"libEGL.so".as_ptr()] {
for soname in EGL_POTENTIAL_SO_NAMES {
unsafe {
let handle = dlopen(soname as *const _, RTLD_LAZY);
let handle = dlopen(soname.as_ptr(), RTLD_LAZY);
if !handle.is_null() {
return EGLLibraryWrapper(handle);
}
Expand Down

0 comments on commit 67a1dd4

Please sign in to comment.