void-packages/srcpkgs/gobject-introspection/patches/0002-Relocate-the-repositor...

77 lines
2.5 KiB
Diff
Raw Normal View History

2019-01-29 14:18:25 +01:00
From 7ea8c83d84a05f686128e652a5447fb5f6fb68be Mon Sep 17 00:00:00 2001
From: Sascha Silbe <x-yo17@se-silbe.de>
Date: Fri, 8 Jun 2018 13:55:10 +0200
Subject: [PATCH] Relocate the repository directory for native builds
Instead of hard-coding GOBJECT_INTROSPECTION_LIBDIR when
gobject-introspection is built, use dladdr() to determine where
GOBJECT_INTROSPECTION_LIBDIR is and use that path to calculate the
repository directory.
This fixes gobject-introspection-native accessing paths across build
directories (e.g. if the build directories use the same shared state
cache or sstate mirror).
Upstream-Status: Inappropriate
Signed-off-by: Sascha Silbe <x-yo17@se-silbe.de>
---
girepository/girepository.c | 15 +++++++++++++--
girepository/meson.build | 2 +-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/girepository/girepository.c b/girepository/girepository.c
index c1fa3d3..efa557e 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -21,6 +21,8 @@
* Boston, MA 02111-1307, USA.
*/
+#define _GNU_SOURCE
+
#include "config.h"
#include <stdio.h>
@@ -34,6 +36,8 @@
#include "gitypelib-internal.h"
#include "girepository-private.h"
+#include <dlfcn.h>
+
/**
* SECTION:girepository
* @short_description: GObject Introspection repository manager
@@ -188,9 +192,16 @@ init_globals (void)
g_free (custom_dirs);
}
- libdir = GOBJECT_INTROSPECTION_LIBDIR;
+ Dl_info gi_lib_info;
- typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
+ if (dladdr (g_irepository_get_default, &gi_lib_info)) {
+ char *libdir = g_path_get_dirname (gi_lib_info.dli_fname);
+ typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
+ g_free (libdir);
+ } else {
+ libdir = GOBJECT_INTROSPECTION_LIBDIR;
+ typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
+ }
typelib_search_path = g_slist_prepend (typelib_search_path, typelib_dir);
diff --git a/girepository/meson.build b/girepository/meson.build
index 6a8c5b5..8892f2a 100644
--- a/girepository/meson.build
+++ b/girepository/meson.build
@@ -27,7 +27,7 @@ girepo_internals_lib = static_library('girepository-internals',
],
c_args: gi_hidden_visibility_cflags,
include_directories : configinc,
- dependencies: [girepo_gthash_dep, libffi_dep],
+ dependencies: [girepo_gthash_dep, libffi_dep, cc.find_library('dl')],
)
girepo_internals_dep = declare_dependency(