1 From fabf8c505181636182a357e0c6e764b752ccf468 Mon Sep 17 00:00:00 2001
2 From: Alexander Kanavin <alex.kanavin@gmail.com>
3 Date: Thu, 15 Nov 2018 15:10:05 +0100
4 Subject: [PATCH] Port cross-compilation support to meson
6 Upstream-Status: Pending
7 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
10 gir/meson.build | 59 ++++++++++++++++++++++++++++++++++-------------
12 meson_options.txt | 20 ++++++++++++++++
13 3 files changed, 66 insertions(+), 17 deletions(-)
15 diff --git a/gir/meson.build b/gir/meson.build
16 index 607bbc45..c0e221b3 100644
19 @@ -37,15 +37,27 @@ typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
20 girdir = join_paths(get_option('datadir'), 'gir-1.0')
21 install_data(gir_files, install_dir: girdir)
26 - '--output=@OUTPUT@',
28 - '--reparse-validate',
29 - '--add-include-path', join_paths(meson.current_build_dir()),
30 - '--add-include-path', join_paths(meson.current_source_dir()),
32 +if get_option('enable-host-gi')
35 + '--output=@OUTPUT@',
37 + '--reparse-validate',
38 + '--add-include-path', join_paths(meson.current_build_dir()),
39 + '--add-include-path', join_paths(meson.current_source_dir()),
45 + '--output=@OUTPUT@',
47 + '--reparse-validate',
48 + '--add-include-path', join_paths(meson.current_build_dir()),
49 + '--add-include-path', join_paths(meson.current_source_dir()),
54 dep_type = glib_dep.type_name()
55 if dep_type == 'internal'
56 @@ -58,6 +70,12 @@ if dep_type == 'internal'
57 '--extra-library=glib-2.0', '--extra-library=gobject-2.0']
60 +if get_option('enable-gi-cross-wrapper') != ''
61 + scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
63 +if get_option('enable-gi-ldd-wrapper') != ''
64 + scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
66 # Take a glob and print to newlines
69 @@ -84,8 +102,8 @@ glib_command = scanner_command + [
71 if dep_type == 'pkgconfig'
72 glib_command += ['--external-library', '--pkg=glib-2.0']
73 - glib_libdir = glib_dep.get_pkgconfig_variable('libdir')
74 - glib_incdir = join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
75 + glib_libdir = get_option('pkgconfig-sysroot-path') + glib_dep.get_pkgconfig_variable('libdir')
76 + glib_incdir = get_option('pkgconfig-sysroot-path') + join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
77 glib_libincdir = join_paths(glib_libdir, 'glib-2.0', 'include')
78 glib_files += join_paths(glib_incdir, 'gobject', 'glib-types.h')
79 glib_files += join_paths(glib_libincdir, 'glibconfig.h')
80 @@ -339,7 +357,7 @@ endforeach
81 if giounix_dep.found()
82 if dep_type == 'pkgconfig'
83 gio_command += ['--pkg=gio-unix-2.0']
84 - giounix_includedir = join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
85 + giounix_includedir = get_option('pkgconfig-sysroot-path') + join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
86 # Get the installed gio-unix header list
87 ret = run_command(python, '-c', globber.format(join_paths(giounix_includedir, 'gio', '*.h')))
88 if ret.returncode() != 0
89 @@ -417,15 +435,24 @@ gir_files += custom_target('gir-girepository',
93 +if get_option('enable-gi-cross-wrapper') != ''
94 + gircompiler_command = [get_option('enable-gi-cross-wrapper'), gircompiler.full_path(), '-o', '@OUTPUT@', '@INPUT@',
95 + '--includedir', meson.current_build_dir(),
96 + '--includedir', meson.current_source_dir(),
99 + gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
100 + '--includedir', meson.current_build_dir(),
101 + '--includedir', meson.current_source_dir(),
105 foreach gir : gir_files
106 custom_target('generate-typelib-@0@'.format(gir).underscorify(),
108 output: '@BASENAME@.typelib',
109 depends: [gobject_gir, ],
110 - command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
111 - '--includedir', meson.current_build_dir(),
112 - '--includedir', meson.current_source_dir(),
114 + command: gircompiler_command,
116 install_dir: typelibdir,
118 diff --git a/meson.build b/meson.build
119 index 7ec95328..9e20da57 100644
122 @@ -76,7 +76,9 @@ libffi_dep = dependency('libffi',
123 subdir('girepository')
127 +if get_option('enable-introspection-data') == true
133 diff --git a/meson_options.txt b/meson_options.txt
134 index 49726be6..d557a3b6 100644
135 --- a/meson_options.txt
136 +++ b/meson_options.txt
137 @@ -21,3 +21,23 @@ option('cairo-libname', type: 'string',
138 option('python', type: 'string', value: 'python3',
139 description: 'Path or name of the Python interpreter to build for'
142 +option('enable-host-gi', type: 'boolean', value : false,
143 + description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
146 +option('enable-gi-cross-wrapper', type: 'string',
147 + description: 'Use a wrapper to run gicompiler and binaries produced by giscanner (useful when cross-compiling)'
150 +option('enable-gi-ldd-wrapper', type: 'string',
151 + description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
154 +option('enable-introspection-data', type: 'boolean', value : true,
155 + description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
158 +option('pkgconfig-sysroot-path', type: 'string',
159 + description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'