From 67a1dd445da6b1f436a15b7a5cf7d98bff663909 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 5 Sep 2024 09:11:51 +0200 Subject: [PATCH] ohos: Only look for `libEGL.so` This avoids needless overhead and error messages in the console when loading `libEGL.so.1` fails. --- src/platform/generic/egl/device.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platform/generic/egl/device.rs b/src/platform/generic/egl/device.rs index 3fde4958..683fd356 100644 --- a/src/platform/generic/egl/device.rs +++ b/src/platform/generic/egl/device.rs @@ -25,11 +25,17 @@ static EGL_LIBRARY: LazyLock = 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 = 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); }