diff options
author | Campbell Barton <campbell@blender.org> | 2022-07-05 07:49:36 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-07-06 08:30:47 +0300 |
commit | e58e023e1a3e10f4ff2557aedcd730b5dba23579 (patch) | |
tree | 6f4383d011e359b13add3dd7917a7e69b4231c0e /intern/wayland_dynload/intern/wayland_dynload_utils.c | |
parent | d9505831a4549e872bcef023ac082d002e8d8392 (diff) |
GHOST/Wayland: support dynamic loading libraries for Wayland
Add intern/wayland_dynload which is used when WITH_GHOST_WAYLAND_DYNLOAD
is enabled (off by default). When enabled, systems without Wayland
installed will fall back to X11.
This allows Blender to dynamically load:
- libwayland-client
- libwayland-cursor
- libwayland-egl
- libdecor-0 (when WITH_GHOST_WAYLAND_LIBDECOR is enabled).
Diffstat (limited to 'intern/wayland_dynload/intern/wayland_dynload_utils.c')
-rw-r--r-- | intern/wayland_dynload/intern/wayland_dynload_utils.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/intern/wayland_dynload/intern/wayland_dynload_utils.c b/intern/wayland_dynload/intern/wayland_dynload_utils.c new file mode 100644 index 00000000000..743dac14eec --- /dev/null +++ b/intern/wayland_dynload/intern/wayland_dynload_utils.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup intern_wayland_dynload + */ + +#include <stdio.h> + +#include "wayland_dynload_utils.h" + +DynamicLibrary dynamic_library_open_array_with_error(const char **paths, + const int paths_num, + const bool verbose, + int *r_path_index) +{ + DynamicLibrary lib = NULL; + for (int a = 0; a < paths_num; a++) { + lib = dynamic_library_open(paths[a]); + if (lib) { + *r_path_index = a; + break; + } + } + if (lib == NULL) { + /* Use the last path as it's likely to be least specific. */ + if (verbose) { + fprintf(stderr, "Unable to find '%s'\n", paths[paths_num - 1]); + } + } + return lib; +} + +void *dynamic_library_find_with_error(DynamicLibrary lib, const char *symbol, const char *path_lib) +{ + void *symbol_var = dynamic_library_find(lib, symbol); + if (symbol_var == NULL) { + fprintf(stderr, "Unable to find '%s' in '%s'.\n", symbol, path_lib); + } + return symbol_var; +} |