]> code.ossystems Code Review - openembedded-core.git/blob
17b9eac057c218eea8ae1975bc36cde755aef776
[openembedded-core.git] /
1 From a20b4d70f44449875b7c54750ab0f02eefb0870d 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  girepository/meson.build    |  2 +-
21  2 files changed, 14 insertions(+), 3 deletions(-)
22
23 diff --git a/girepository/girepository.c b/girepository/girepository.c
24 index c1fa3d3..efa557e 100644
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
45 @@ -188,9 +192,16 @@ init_globals (void)
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  
64 diff --git a/girepository/meson.build b/girepository/meson.build
65 index 6a8c5b5..8892f2a 100644
66 --- a/girepository/meson.build
67 +++ b/girepository/meson.build
68 @@ -27,7 +27,7 @@ girepo_internals_lib = static_library('girepository-internals',
69    ],
70    c_args: gi_hidden_visibility_cflags,
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(