Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 1 | From 74a0fee892235c722ac60ddea6ee79bc3d7a93f5 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 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 +++++++++++++-- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 20 | girepository/meson.build | 2 +- |
| 21 | 2 files changed, 14 insertions(+), 3 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 22 | |
| 23 | diff --git a/girepository/girepository.c b/girepository/girepository.c |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 24 | index 7d03485..20f4813 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 25 | --- 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 45 | @@ -215,9 +219,16 @@ init_globals (void) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 64 | diff --git a/girepository/meson.build b/girepository/meson.build |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 65 | index 786749a..15cf2a9 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 66 | --- a/girepository/meson.build |
| 67 | +++ b/girepository/meson.build |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 68 | @@ -45,7 +45,7 @@ girepo_internals_lib = static_library('girepository-internals', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 69 | ], |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 70 | c_args: gi_hidden_visibility_cflags + custom_c_args, |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 71 | 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( |