[glib: 1/2] giomodule: Automatically detect modules on macOS
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] giomodule: Automatically detect modules on macOS
- Date: Fri, 14 Oct 2022 15:29:10 +0000 (UTC)
commit af83c6571e47d06468b8162dd29ad57bcf4967a8
Author: Piotr BrzeziĆski <piotr centricular com>
Date: Tue Aug 9 10:42:39 2022 +0200
giomodule: Automatically detect modules on macOS
Makes use of relocatable prefixes, allowing gio to find modules
automatically without needing to set the GIO_EXTRA_MODULES env var.
gio/giomodule.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/gio/giomodule.c b/gio/giomodule.c
index f5dbb4555f..fce60e9fc5 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -1262,6 +1262,29 @@ get_gio_module_dir (void)
g_free (install_dir);
#else
module_dir = g_strdup (GIO_MODULE_DIR);
+#ifdef __APPLE__
+#include "TargetConditionals.h"
+#if TARGET_OS_OSX
+#include <dlfcn.h>
+ {
+ g_autofree gchar *path = NULL;
+ g_autofree gchar *possible_dir = NULL;
+ Dl_info info;
+
+ if (dladdr (get_gio_module_dir, &info))
+ {
+ /* Gets path to the PREFIX/lib directory */
+ path = g_path_get_dirname (info.dli_fname);
+ possible_dir = g_build_filename (path, "gio", "modules", NULL);
+ if (g_file_test (possible_dir, G_FILE_TEST_IS_DIR))
+ {
+ g_free (module_dir);
+ module_dir = g_steal_pointer (&possible_dir);
+ }
+ }
+ }
+#endif
+#endif
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]