blob: 030ff176010d313a78106aea31b40ce68af283fa [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From d396e5126461631e2c73ce98ba034f1e44598f6a Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Sascha Silbe <x-yo17@se-silbe.de>
3Date: Fri, 8 Jun 2018 13:55:10 +0200
4Subject: [PATCH] Relocate the repository directory for native builds
5
6Instead of hard-coding GOBJECT_INTROSPECTION_LIBDIR when
7gobject-introspection is built, use dladdr() to determine where
8GOBJECT_INTROSPECTION_LIBDIR is and use that path to calculate the
9repository directory.
10
11This fixes gobject-introspection-native accessing paths across build
12directories (e.g. if the build directories use the same shared state
13cache or sstate mirror).
14
15Upstream-Status: Inappropriate
16Signed-off-by: Sascha Silbe <x-yo17@se-silbe.de>
17
18---
19 girepository/girepository.c | 15 +++++++++++++--
Brad Bishop19323692019-04-05 15:28:33 -040020 girepository/meson.build | 2 +-
21 2 files changed, 14 insertions(+), 3 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022
23diff --git a/girepository/girepository.c b/girepository/girepository.c
Andrew Geissler517393d2023-01-13 08:55:19 -060024index a0754f4..2d456f9 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025--- a/girepository/girepository.c
26+++ b/girepository/girepository.c
27@@ -21,6 +21,8 @@
28 * Boston, MA 02111-1307, USA.
29 */
30
31+#define _GNU_SOURCE
32+
33 #include "config.h"
34
35 #include <stdio.h>
36@@ -34,6 +36,8 @@
37 #include "gitypelib-internal.h"
38 #include "girepository-private.h"
39
40+#include <dlfcn.h>
41+
42 /**
43 * SECTION:girepository
44 * @short_description: GObject Introspection repository manager
Andrew Geissler82c905d2020-04-13 13:39:40 -050045@@ -215,9 +219,16 @@ init_globals (void)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046 g_free (custom_dirs);
47 }
48
49- libdir = GOBJECT_INTROSPECTION_LIBDIR;
50+ Dl_info gi_lib_info;
51
52- typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
53+ if (dladdr (g_irepository_get_default, &gi_lib_info)) {
54+ char *libdir = g_path_get_dirname (gi_lib_info.dli_fname);
55+ typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
56+ g_free (libdir);
57+ } else {
58+ libdir = GOBJECT_INTROSPECTION_LIBDIR;
59+ typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
60+ }
61
62 typelib_search_path = g_slist_prepend (typelib_search_path, typelib_dir);
63
Brad Bishop19323692019-04-05 15:28:33 -040064diff --git a/girepository/meson.build b/girepository/meson.build
Andrew Geisslereff27472021-10-29 15:35:00 -050065index 786749a..15cf2a9 100644
Brad Bishop19323692019-04-05 15:28:33 -040066--- a/girepository/meson.build
67+++ b/girepository/meson.build
Andrew Geissler6ce62a22020-11-30 19:58:47 -060068@@ -45,7 +45,7 @@ girepo_internals_lib = static_library('girepository-internals',
Brad Bishop19323692019-04-05 15:28:33 -040069 ],
Brad Bishopc342db32019-05-15 21:57:59 -040070 c_args: gi_hidden_visibility_cflags + custom_c_args,
Brad Bishop19323692019-04-05 15:28:33 -040071 include_directories : configinc,
72- dependencies: [girepo_gthash_dep, libffi_dep],
73+ dependencies: [girepo_gthash_dep, libffi_dep, cc.find_library('dl')],
74 )
75
76 girepo_internals_dep = declare_dependency(