1 From 0417a1bb08745f2bf5310d20b342c2b3b9b212d3 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 | 62 ++++++++++++++++++++++++++++++++++-------------
12 meson_options.txt | 20 +++++++++++++++
13 3 files changed, 68 insertions(+), 18 deletions(-)
15 diff --git a/gir/meson.build b/gir/meson.build
16 index c312100..a028033 100644
19 @@ -41,16 +41,29 @@ gir_files = [
20 typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
21 install_data(gir_files, install_dir: girdir)
26 - '--output=@OUTPUT@',
29 - '--reparse-validate',
30 - '--add-include-path', join_paths(meson.current_build_dir()),
31 - '--add-include-path', join_paths(meson.current_source_dir()),
33 +if get_option('enable-host-gi')
36 + '--output=@OUTPUT@',
39 + '--reparse-validate',
40 + '--add-include-path', join_paths(meson.current_build_dir()),
41 + '--add-include-path', join_paths(meson.current_source_dir()),
47 + '--output=@OUTPUT@',
50 + '--reparse-validate',
51 + '--add-include-path', join_paths(meson.current_build_dir()),
52 + '--add-include-path', join_paths(meson.current_source_dir()),
57 dep_type = glib_dep.type_name()
58 if dep_type == 'internal'
59 @@ -63,6 +76,12 @@ if dep_type == 'internal'
60 '--extra-library=glib-2.0', '--extra-library=gobject-2.0']
63 +if get_option('enable-gi-cross-wrapper') != ''
64 + scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
66 +if get_option('enable-gi-ldd-wrapper') != ''
67 + scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
69 # Take a glob and print to newlines
72 @@ -89,8 +108,8 @@ glib_command = scanner_command + [
74 if dep_type == 'pkgconfig'
75 glib_command += ['--external-library', '--pkg=glib-2.0']
76 - glib_libdir = glib_dep.get_pkgconfig_variable('libdir')
77 - glib_incdir = join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
78 + glib_libdir = get_option('pkgconfig-sysroot-path') + glib_dep.get_pkgconfig_variable('libdir')
79 + glib_incdir = get_option('pkgconfig-sysroot-path') + join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
80 glib_libincdir = join_paths(glib_libdir, 'glib-2.0', 'include')
81 glib_files += join_paths(glib_incdir, 'gobject', 'glib-types.h')
82 glib_files += join_paths(glib_libincdir, 'glibconfig.h')
83 @@ -345,7 +364,7 @@ if giounix_dep.found()
84 dep_type = giounix_dep.type_name()
85 if dep_type == 'pkgconfig'
86 gio_command += ['--pkg=gio-unix-2.0']
87 - giounix_includedir = join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
88 + giounix_includedir = get_option('pkgconfig-sysroot-path') + join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
89 # Get the installed gio-unix header list
90 ret = run_command(python, '-c', globber.format(join_paths(giounix_includedir, 'gio', '*.h')))
91 if ret.returncode() != 0
92 @@ -428,15 +447,24 @@ gir_files += custom_target('gir-girepository',
96 +if get_option('enable-gi-cross-wrapper') != ''
97 + gircompiler_command = [get_option('enable-gi-cross-wrapper'), gircompiler.full_path(), '-o', '@OUTPUT@', '@INPUT@',
98 + '--includedir', meson.current_build_dir(),
99 + '--includedir', meson.current_source_dir(),
102 + gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
103 + '--includedir', meson.current_build_dir(),
104 + '--includedir', meson.current_source_dir(),
108 foreach gir : gir_files
109 typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(),
111 output: '@BASENAME@.typelib',
112 depends: [gobject_gir, ],
113 - command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
114 - '--includedir', meson.current_build_dir(),
115 - '--includedir', meson.current_source_dir(),
117 + command: gircompiler_command,
119 install_dir: typelibdir,
121 diff --git a/meson.build b/meson.build
122 index a5e825f..a28490a 100644
125 @@ -168,7 +168,9 @@ endif
126 subdir('girepository')
130 +if get_option('enable-introspection-data') == true
136 diff --git a/meson_options.txt b/meson_options.txt
137 index 445a68a..a325511 100644
138 --- a/meson_options.txt
139 +++ b/meson_options.txt
140 @@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3',
141 option('gir_dir_prefix', type: 'string',
142 description: 'Intermediate prefix for gir installation under ${prefix}'
145 +option('enable-host-gi', type: 'boolean', value : false,
146 + description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
149 +option('enable-gi-cross-wrapper', type: 'string',
150 + description: 'Use a wrapper to run gicompiler and binaries produced by giscanner (useful when cross-compiling)'
153 +option('enable-gi-ldd-wrapper', type: 'string',
154 + description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
157 +option('enable-introspection-data', type: 'boolean', value : true,
158 + description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
161 +option('pkgconfig-sysroot-path', type: 'string',
162 + description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'