base-dirs: add support for finding modules and remove wp_get_module_dir()

This makes things more consistent and allows us also to add more
search paths in the future if necessary.

Also, stop using g_module_build_path() because it's deprecated and
build the path manually. This obviously is not portable to Windows/Mac
or other exotic platforms, but portability is not important at this
point. PipeWire is also not portable beyond Linux & BSD.
This commit is contained in:
George Kiagiadakis
2024-02-27 11:59:33 +02:00
parent c8feaad7a9
commit f76f45124e
5 changed files with 73 additions and 42 deletions

View File

@@ -698,10 +698,12 @@ load_module (WpCore * core, const gchar * module_name, WpSpaJson * args,
GModule *gmodule;
gpointer module_init;
if (!g_file_test (module_name, G_FILE_TEST_EXISTS))
module_path = g_module_build_path (wp_get_module_dir (), module_name);
else
module_path = g_strdup (module_name);
module_path = wp_base_dirs_find_file (WP_BASE_DIRS_MODULE, NULL, module_name);
if (!module_path) {
g_set_error (error, WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
"Failed to locate module %s", module_name);
return NULL;
}
wp_trace_object (core, "loading %s from %s", module_name, module_path);