Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 4cf37d56fddcc22bcd818f6d470404f56d907f3c 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 |
| 5 | |
| 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 |
| 9 | repository directory. |
| 10 | |
| 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). |
| 14 | |
| 15 | Upstream-Status: Inappropriate |
| 16 | Signed-off-by: Sascha Silbe <x-yo17@se-silbe.de> |
| 17 | |
| 18 | --- |
| 19 | girepository/girepository.c | 15 +++++++++++++-- |
| 20 | 1 file changed, 13 insertions(+), 2 deletions(-) |
| 21 | |
| 22 | diff --git a/girepository/girepository.c b/girepository/girepository.c |
| 23 | index c1fa3d3..efa557e 100644 |
| 24 | --- a/girepository/girepository.c |
| 25 | +++ b/girepository/girepository.c |
| 26 | @@ -21,6 +21,8 @@ |
| 27 | * Boston, MA 02111-1307, USA. |
| 28 | */ |
| 29 | |
| 30 | +#define _GNU_SOURCE |
| 31 | + |
| 32 | #include "config.h" |
| 33 | |
| 34 | #include <stdio.h> |
| 35 | @@ -34,6 +36,8 @@ |
| 36 | #include "gitypelib-internal.h" |
| 37 | #include "girepository-private.h" |
| 38 | |
| 39 | +#include <dlfcn.h> |
| 40 | + |
| 41 | /** |
| 42 | * SECTION:girepository |
| 43 | * @short_description: GObject Introspection repository manager |
| 44 | @@ -188,9 +192,16 @@ init_globals (void) |
| 45 | g_free (custom_dirs); |
| 46 | } |
| 47 | |
| 48 | - libdir = GOBJECT_INTROSPECTION_LIBDIR; |
| 49 | + Dl_info gi_lib_info; |
| 50 | |
| 51 | - typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL); |
| 52 | + if (dladdr (g_irepository_get_default, &gi_lib_info)) { |
| 53 | + char *libdir = g_path_get_dirname (gi_lib_info.dli_fname); |
| 54 | + typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL); |
| 55 | + g_free (libdir); |
| 56 | + } else { |
| 57 | + libdir = GOBJECT_INTROSPECTION_LIBDIR; |
| 58 | + typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL); |
| 59 | + } |
| 60 | |
| 61 | typelib_search_path = g_slist_prepend (typelib_search_path, typelib_dir); |
| 62 | |