7687a396e8
GObject introspection is a middleware layer between C libraries (using GObject) and language bindings. The C library can be scanned at compile time and generate a metadata file, in addition to the actual native C library. Then at runtime, language bindings can read this metadata and automatically provide bindings to call into the C library. There's an XML format called GIR used by GObject-Introspection. The purpose of it is to provide a standard structure to access the complete available API that a library or other unit of code exports. It's language-agnostic using namespaces to separate core, language, or library-specific functionality. Cross-compiling gobject-introspection is not an easy task. The main issue is that in the process of creating the XML files, gobject-introspection must first run and scan the binary, which, if the binary is cross-compiled, would not typically be possible from the host system. Because of this limitation, we use several wrappers to call instead first out qemu, which runs the native scanner to create the binaries. There are seven total patches and four different wrapper files needed to successfully cross-compile and run this package, many of them are from open-embedded, but one of them is of my own doing. 1) Revert a previous, incomplete attempt at adding cross-compiling support. 2) Add support for cross-compiling with meson. 3) Disable tests. 4) Add an option to use a binary wrapper; this patch will force giscanner to use a wrapper executable to run binaries it's producing, instead of attempting to run them from the host. 5) Add an option to use an LDD wrapper, again, useful for cross-compiled environments. 6) Add a --lib-dirs-envar option to pass to giscanner. (See patch for details.) 7) Add rpath-links to ccompiler: when passing the PACKAGE_GIR_EXTRA_LIBS_PATH to the ccompiler.py script, ccompiler.py needs to add -Wl,-rpath-link to the environment for the package to correctly link against the passed on paths. 8) Ignore error return codes from ldd-wrapper because prelink-rtld returns 127 when it can't find a library, which breaks subprocess.check_output(). Signed-off-by: Adam Duskett <Aduskett@gmail.com> Tested-by: Yegor Yefremov <yegorslists@googlemail.com> Tested-by: Giulio Benetti <giulio.benetti@benettiengineering.com> [yann.morin.1998@free.fr: - host-prelink-cross has no Kconfig entry - reorder dependencies for arch deps first ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
164 lines
5.9 KiB
Diff
164 lines
5.9 KiB
Diff
From 2b3bce1526b538dc2c7fa223eaf9808858aa1b06 Mon Sep 17 00:00:00 2001
|
|
From: Alexander Kanavin <alex.kanavin@gmail.com>
|
|
Date: Thu, 15 Nov 2018 15:10:05 +0100
|
|
Subject: [PATCH] add cross-compilation support to meson
|
|
|
|
Upstream-Status: Pending
|
|
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
|
|
Signed-off-by: Adam Duskett <aduskett@gmail.com>
|
|
---
|
|
gir/meson.build | 62 ++++++++++++++++++++++++++++++++++-------------
|
|
meson.build | 4 ++-
|
|
meson_options.txt | 20 +++++++++++++++
|
|
3 files changed, 68 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/gir/meson.build b/gir/meson.build
|
|
index 85ae575..327c134 100644
|
|
--- a/gir/meson.build
|
|
+++ b/gir/meson.build
|
|
@@ -36,16 +36,29 @@ gir_files = [
|
|
typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
|
|
install_data(gir_files, install_dir: girdir)
|
|
|
|
-scanner_command = [
|
|
- python,
|
|
- girscanner,
|
|
- '--output=@OUTPUT@',
|
|
- '--no-libtool',
|
|
- '--quiet',
|
|
- '--reparse-validate',
|
|
- '--add-include-path', join_paths(meson.current_build_dir()),
|
|
- '--add-include-path', join_paths(meson.current_source_dir()),
|
|
-]
|
|
+if get_option('enable-host-gi')
|
|
+ scanner_command = [
|
|
+ 'g-ir-scanner',
|
|
+ '--output=@OUTPUT@',
|
|
+ '--no-libtool',
|
|
+ '--quiet',
|
|
+ '--reparse-validate',
|
|
+ '--add-include-path', join_paths(meson.current_build_dir()),
|
|
+ '--add-include-path', join_paths(meson.current_source_dir()),
|
|
+ ]
|
|
+else
|
|
+ scanner_command = [
|
|
+ python,
|
|
+ girscanner,
|
|
+ '--output=@OUTPUT@',
|
|
+ '--no-libtool',
|
|
+ '--quiet',
|
|
+ '--reparse-validate',
|
|
+ '--add-include-path', join_paths(meson.current_build_dir()),
|
|
+ '--add-include-path', join_paths(meson.current_source_dir()),
|
|
+ ]
|
|
+endif
|
|
+
|
|
|
|
dep_type = glib_dep.type_name()
|
|
if dep_type == 'internal'
|
|
@@ -58,6 +71,12 @@ if dep_type == 'internal'
|
|
'--extra-library=glib-2.0', '--extra-library=gobject-2.0']
|
|
endif
|
|
|
|
+if get_option('enable-gi-cross-wrapper') != ''
|
|
+ scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
|
|
+endif
|
|
+if get_option('enable-gi-ldd-wrapper') != ''
|
|
+ scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
|
|
+endif
|
|
# Take a glob and print to newlines
|
|
globber = '''
|
|
from glob import glob
|
|
@@ -84,8 +103,8 @@ glib_command = scanner_command + [
|
|
|
|
if dep_type == 'pkgconfig'
|
|
glib_command += ['--external-library', '--pkg=glib-2.0']
|
|
- glib_libdir = glib_dep.get_pkgconfig_variable('libdir')
|
|
- glib_incdir = join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
|
|
+ glib_libdir = get_option('pkgconfig-sysroot-path') + glib_dep.get_pkgconfig_variable('libdir')
|
|
+ glib_incdir = get_option('pkgconfig-sysroot-path') + join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
|
|
glib_libincdir = join_paths(glib_libdir, 'glib-2.0', 'include')
|
|
glib_files += join_paths(glib_incdir, 'gobject', 'glib-types.h')
|
|
glib_files += join_paths(glib_libincdir, 'glibconfig.h')
|
|
@@ -339,7 +358,7 @@ endforeach
|
|
if giounix_dep.found()
|
|
if dep_type == 'pkgconfig'
|
|
gio_command += ['--pkg=gio-unix-2.0']
|
|
- giounix_includedir = join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
|
|
+ giounix_includedir = get_option('pkgconfig-sysroot-path') + join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
|
|
# Get the installed gio-unix header list
|
|
ret = run_command(python, '-c', globber.format(join_paths(giounix_includedir, 'gio', '*.h')))
|
|
if ret.returncode() != 0
|
|
@@ -422,15 +441,24 @@ gir_files += custom_target('gir-girepository',
|
|
)
|
|
|
|
typelibs = []
|
|
+if get_option('enable-gi-cross-wrapper') != ''
|
|
+ gircompiler_command = [get_option('enable-gi-cross-wrapper'), gircompiler.full_path(), '-o', '@OUTPUT@', '@INPUT@',
|
|
+ '--includedir', meson.current_build_dir(),
|
|
+ '--includedir', meson.current_source_dir(),
|
|
+ ]
|
|
+else
|
|
+ gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
|
|
+ '--includedir', meson.current_build_dir(),
|
|
+ '--includedir', meson.current_source_dir(),
|
|
+ ]
|
|
+endif
|
|
+
|
|
foreach gir : gir_files
|
|
typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(),
|
|
input: gir,
|
|
output: '@BASENAME@.typelib',
|
|
depends: [gobject_gir, ],
|
|
- command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
|
|
- '--includedir', meson.current_build_dir(),
|
|
- '--includedir', meson.current_source_dir(),
|
|
- ],
|
|
+ command: gircompiler_command,
|
|
install: true,
|
|
install_dir: typelibdir,
|
|
)
|
|
diff --git a/meson.build b/meson.build
|
|
index 95bbd2b..f7baefd 100644
|
|
--- a/meson.build
|
|
+++ b/meson.build
|
|
@@ -163,7 +163,9 @@ endif
|
|
subdir('girepository')
|
|
subdir('tools')
|
|
subdir('giscanner')
|
|
-subdir('gir')
|
|
+if get_option('enable-introspection-data') == true
|
|
+ subdir('gir')
|
|
+endif
|
|
subdir('examples')
|
|
subdir('docs')
|
|
subdir('tests')
|
|
diff --git a/meson_options.txt b/meson_options.txt
|
|
index 445a68a..a325511 100644
|
|
--- a/meson_options.txt
|
|
+++ b/meson_options.txt
|
|
@@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3',
|
|
option('gir_dir_prefix', type: 'string',
|
|
description: 'Intermediate prefix for gir installation under ${prefix}'
|
|
)
|
|
+
|
|
+option('enable-host-gi', type: 'boolean', value : false,
|
|
+ description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
|
|
+)
|
|
+
|
|
+option('enable-gi-cross-wrapper', type: 'string',
|
|
+ description: 'Use a wrapper to run gicompiler and binaries produced by giscanner (useful when cross-compiling)'
|
|
+)
|
|
+
|
|
+option('enable-gi-ldd-wrapper', type: 'string',
|
|
+ description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
|
|
+)
|
|
+
|
|
+option('enable-introspection-data', type: 'boolean', value : true,
|
|
+ description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
|
|
+)
|
|
+
|
|
+option('pkgconfig-sysroot-path', type: 'string',
|
|
+ description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'
|
|
+)
|