summaryrefslogtreecommitdiffstats
path: root/meta/recipes-gnome/gobject-introspection/gobject-introspection/0001-Relocate-the-repository-directory-for-native-builds.patch
blob: 644cab929dd67dd02c1cc9082b3d563aad451f01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 31ef4cce83c1770ea1e816d91b7e258fbf170035 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 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/girepository/girepository.c b/girepository/girepository.c
index 10282c72..60c45104 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
@@ -191,9 +195,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);
+      }
 
       search_path = g_slist_prepend (search_path, typelib_dir);
 
-- 
2.11.0