1 From 8dfb44450ca9fffc15977e95eadcb7054ab60a9a Mon Sep 17 00:00:00 2001
2 From: Sascha Silbe <x-yo17@se-silbe.de>
3 Date: Fri, 8 Jun 2018 13:55:10 +0200
4 Subject: [PATCH] Relocate the repository directory for native builds
6 Instead of hard-coding GOBJECT_INTROSPECTION_LIBDIR when
7 gobject-introspection is built, use dladdr() to determine where
8 GOBJECT_INTROSPECTION_LIBDIR is and use that path to calculate the
11 This fixes gobject-introspection-native accessing paths across build
12 directories (e.g. if the build directories use the same shared state
13 cache or sstate mirror).
15 Upstream-Status: Inappropriate
16 Signed-off-by: Sascha Silbe <x-yo17@se-silbe.de>
19 girepository/girepository.c | 15 +++++++++++++--
20 girepository/meson.build | 2 +-
21 2 files changed, 14 insertions(+), 3 deletions(-)
23 diff --git a/girepository/girepository.c b/girepository/girepository.c
24 index b7948d6..39a2586 100644
25 --- a/girepository/girepository.c
26 +++ b/girepository/girepository.c
28 * Boston, MA 02111-1307, USA.
37 #include "gitypelib-internal.h"
38 #include "girepository-private.h"
43 * SECTION:girepository
44 * @short_description: GObject Introspection repository manager
45 @@ -215,9 +219,16 @@ init_globals (void)
49 - libdir = GOBJECT_INTROSPECTION_LIBDIR;
50 + Dl_info gi_lib_info;
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);
58 + libdir = GOBJECT_INTROSPECTION_LIBDIR;
59 + typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
62 typelib_search_path = g_slist_prepend (typelib_search_path, typelib_dir);
64 diff --git a/girepository/meson.build b/girepository/meson.build
65 index 204659f..3e61d31 100644
66 --- a/girepository/meson.build
67 +++ b/girepository/meson.build
68 @@ -44,7 +44,7 @@ girepo_internals_lib = static_library('girepository-internals',
70 c_args: gi_hidden_visibility_cflags + custom_c_args,
71 include_directories : configinc,
72 - dependencies: [girepo_gthash_dep, libffi_dep],
73 + dependencies: [girepo_gthash_dep, libffi_dep, cc.find_library('dl')],
76 girepo_internals_dep = declare_dependency(