# Fix library search path on non-/usr/local installs (e.g. Apple Silicon) # See: https://github.com/Homebrew/homebrew-core/issues/75020 # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/273` --- girepository/gitypelib.c.orig +++ girepository/gitypelib.c @@ -2261,6 +2261,22 @@ load_one_shared_library (const char *shlib) { GSList *p; GModule *m; +#ifdef EXTRA_LIBRARY_PATHS + static gsize extra_libs_initialized = 0; + + if (g_once_init_enter (&extra_libs_initialized)) + { + gchar **paths = g_strsplit(EXTRA_LIBRARY_PATHS, G_SEARCHPATH_SEPARATOR_S, 0); + gint i; + gsize initialized = 1; + for (i = g_strv_length(paths) - 1 ; i >= 0 ; i--) + { + g_irepository_prepend_library_path(paths[i]); + } + g_strfreev(paths); + g_once_init_leave (&extra_libs_initialized, initialized); + } +#endif #ifdef __APPLE__ /* On macOS, @-prefixed shlib paths (@rpath, @executable_path, @loader_path) --- meson.build.orig +++ meson.build @@ -222,6 +222,10 @@ if host_system in ['windows', 'cygwin'] g_ir_scanner_env.prepend(var, gio_dep.get_variable('giomoduledir')) endif +if get_option('extra_library_paths') != '' + config.set_quoted('EXTRA_LIBRARY_PATHS', get_option('extra_library_paths')) +endif + configure_file( configuration: config, output: 'config.h' --- meson_options.txt.orig +++ meson_options.txt @@ -49,3 +49,7 @@ option('gi_cross_pkgconfig_sysroot_path', type: 'string', option('tests', type: 'boolean', value: true, description: 'Build and run tests' ) + +option('extra_library_paths', type: 'string', + description: 'A list of file paths, joined together using the searchpath separator character, that will be used to search for shared libraries' +)