1 From e8ce42c5cb54847517fe8fbe50bbaea452618218 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>
9 gir/meson.build | 59 ++++++++++++++++++++++++++++++++++-------------
11 meson_options.txt | 20 ++++++++++++++++
12 3 files changed, 66 insertions(+), 17 deletions(-)
14 diff --git a/gir/meson.build b/gir/meson.build
15 index 607bbc4..c0e221b 100644
18 @@ -37,15 +37,27 @@ typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
19 girdir = join_paths(get_option('datadir'), 'gir-1.0')
20 install_data(gir_files, install_dir: girdir)
25 - '--output=@OUTPUT@',
27 - '--reparse-validate',
28 - '--add-include-path', join_paths(meson.current_build_dir()),
29 - '--add-include-path', join_paths(meson.current_source_dir()),
31 +if get_option('enable-host-gi')
34 + '--output=@OUTPUT@',
36 + '--reparse-validate',
37 + '--add-include-path', join_paths(meson.current_build_dir()),
38 + '--add-include-path', join_paths(meson.current_source_dir()),
44 + '--output=@OUTPUT@',
46 + '--reparse-validate',
47 + '--add-include-path', join_paths(meson.current_build_dir()),
48 + '--add-include-path', join_paths(meson.current_source_dir()),
53 dep_type = glib_dep.type_name()
54 if dep_type == 'internal'
55 @@ -58,6 +70,12 @@ if dep_type == 'internal'
56 '--extra-library=glib-2.0', '--extra-library=gobject-2.0']
59 +if get_option('enable-gi-cross-wrapper') != ''
60 + scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
62 +if get_option('enable-gi-ldd-wrapper') != ''
63 + scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
65 # Take a glob and print to newlines
68 @@ -84,8 +102,8 @@ glib_command = scanner_command + [
70 if dep_type == 'pkgconfig'
71 glib_command += ['--external-library', '--pkg=glib-2.0']
72 - glib_libdir = glib_dep.get_pkgconfig_variable('libdir')
73 - glib_incdir = join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
74 + glib_libdir = get_option('pkgconfig-sysroot-path') + glib_dep.get_pkgconfig_variable('libdir')
75 + glib_incdir = get_option('pkgconfig-sysroot-path') + join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
76 glib_libincdir = join_paths(glib_libdir, 'glib-2.0', 'include')
77 glib_files += join_paths(glib_incdir, 'gobject', 'glib-types.h')
78 glib_files += join_paths(glib_libincdir, 'glibconfig.h')
79 @@ -339,7 +357,7 @@ endforeach
80 if giounix_dep.found()
81 if dep_type == 'pkgconfig'
82 gio_command += ['--pkg=gio-unix-2.0']
83 - giounix_includedir = join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
84 + giounix_includedir = get_option('pkgconfig-sysroot-path') + join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
85 # Get the installed gio-unix header list
86 ret = run_command(python, '-c', globber.format(join_paths(giounix_includedir, 'gio', '*.h')))
87 if ret.returncode() != 0
88 @@ -417,15 +435,24 @@ gir_files += custom_target('gir-girepository',
92 +if get_option('enable-gi-cross-wrapper') != ''
93 + gircompiler_command = [get_option('enable-gi-cross-wrapper'), gircompiler.full_path(), '-o', '@OUTPUT@', '@INPUT@',
94 + '--includedir', meson.current_build_dir(),
95 + '--includedir', meson.current_source_dir(),
98 + gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
99 + '--includedir', meson.current_build_dir(),
100 + '--includedir', meson.current_source_dir(),
104 foreach gir : gir_files
105 custom_target('generate-typelib-@0@'.format(gir).underscorify(),
107 output: '@BASENAME@.typelib',
108 depends: [gobject_gir, ],
109 - command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
110 - '--includedir', meson.current_build_dir(),
111 - '--includedir', meson.current_source_dir(),
113 + command: gircompiler_command,
115 install_dir: typelibdir,
117 diff --git a/meson.build b/meson.build
118 index 7ec9532..9e20da5 100644
121 @@ -76,7 +76,9 @@ libffi_dep = dependency('libffi',
122 subdir('girepository')
126 +if get_option('enable-introspection-data') == true
132 diff --git a/meson_options.txt b/meson_options.txt
133 index 49726be..3e17c78 100644
134 --- a/meson_options.txt
135 +++ b/meson_options.txt
136 @@ -21,3 +21,23 @@ option('cairo-libname', type: 'string',
137 option('python', type: 'string', value: 'python3',
138 description: 'Path or name of the Python interpreter to build for'
141 +option('enable-host-gi', type: 'boolean', value : false,
142 + description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
145 +option('enable-gi-cross-wrapper', type: 'string',
146 + description: 'Use a wrapper to run gicompiler and binaries produced by giscanner (useful when cross-compiling)'
149 +option('enable-gi-ldd-wrapper', type: 'string',
150 + description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
153 +option('enable-introspection-data', type: 'boolean', value : false,
154 + description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
157 +option('pkgconfig-sysroot-path', type: 'string',
158 + description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'