summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2018-11-15 15:10:05 +0100
committerAlexander Kanavin <alex.kanavin@gmail.com>2019-12-13 17:07:51 +0100
commit1707d9b215aa85fd3aca56555ad14f02b3bd0afe (patch)
tree24c28faa9e7d928e950e04113328650cb784e39f
parent48f41930a773bdd48b9664b2fc5b1e45d6bc5688 (diff)
downloadgobject-introspection-1707d9b215aa85fd3aca56555ad14f02b3bd0afe.tar.gz
meson_options.txt: add host-gi, gi-cross-wrapper, gi-ldd-wrapper, introspection-data and pkgconfig-sysroot-path options
With the first option, gobject-introspection tools (g-ir-doc-tool and g-ir-scanner) that are already installed in the host system will be used for building the source tree. With the second option, g-ir-scanner will be instructed to use an executable wrapper to run binaries it's producing, and g-ir-compiler will be run through the same wrapper (host system's g-ir-compiler cannot be used because it's producing architecture-specific output). With the third option, giscanner will be instructed to use a special ldd command instead of system's ldd (which does not work when the binary to inspect is compiled for a different architecture). With the fourth option, it is possible to disable building of introspection data (.gir and .typelib files), which may be difficult or impossible in cross-compilation environments, because of lack of emulation (or native hardware) for the target architecture on which the target binaries can be run. With the fifth option, paths returned by pkg-config are prefixed with the sysroot path (which is the destination path for cross-compiled items on the system where cross-compilation happens). These options are useful when cross-compiling for a different target architecture. Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
-rw-r--r--gir/meson.build62
-rw-r--r--meson.build4
-rw-r--r--meson_options.txt20
3 files changed, 68 insertions, 18 deletions
diff --git a/gir/meson.build b/gir/meson.build
index c312100c..a0280330 100644
--- a/gir/meson.build
+++ b/gir/meson.build
@@ -41,16 +41,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'
@@ -63,6 +76,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
@@ -89,8 +108,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')
@@ -345,7 +364,7 @@ if giounix_dep.found()
dep_type = giounix_dep.type_name()
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
@@ -428,15 +447,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 df18e467..f8f52d14 100644
--- a/meson.build
+++ b/meson.build
@@ -196,7 +196,9 @@ endif
subdir('girepository')
subdir('tools')
subdir('giscanner')
-subdir('gir')
+if get_option('enable-introspection-data') == true
+ subdir('gir')
+endif
subdir('docs')
subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
index 7bed278d..98491032 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)'
+)