blob: 5747d61c192fffaa1568a7b11c97d62ea5cb5728 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001From 2b3bce1526b538dc2c7fa223eaf9808858aa1b06 Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Thu, 15 Nov 2018 15:10:05 +0100
4Subject: [PATCH] Port cross-compilation support to meson
5
6Upstream-Status: Pending
7Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
8
9---
Brad Bishopc342db32019-05-15 21:57:59 -040010 gir/meson.build | 62 ++++++++++++++++++++++++++++++++++-------------
11 meson.build | 4 ++-
12 meson_options.txt | 20 +++++++++++++++
13 3 files changed, 68 insertions(+), 18 deletions(-)
Brad Bishop19323692019-04-05 15:28:33 -040014
15diff --git a/gir/meson.build b/gir/meson.build
Brad Bishopc342db32019-05-15 21:57:59 -040016index 85ae575..327c134 100644
Brad Bishop19323692019-04-05 15:28:33 -040017--- a/gir/meson.build
18+++ b/gir/meson.build
Brad Bishopc342db32019-05-15 21:57:59 -040019@@ -36,16 +36,29 @@ gir_files = [
Brad Bishop19323692019-04-05 15:28:33 -040020 typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
21 install_data(gir_files, install_dir: girdir)
22
23-scanner_command = [
24- python,
25- girscanner,
26- '--output=@OUTPUT@',
27- '--no-libtool',
Brad Bishopc342db32019-05-15 21:57:59 -040028- '--quiet',
Brad Bishop19323692019-04-05 15:28:33 -040029- '--reparse-validate',
30- '--add-include-path', join_paths(meson.current_build_dir()),
31- '--add-include-path', join_paths(meson.current_source_dir()),
32-]
33+if get_option('enable-host-gi')
34+ scanner_command = [
35+ 'g-ir-scanner',
36+ '--output=@OUTPUT@',
37+ '--no-libtool',
Brad Bishopc342db32019-05-15 21:57:59 -040038+ '--quiet',
Brad Bishop19323692019-04-05 15:28:33 -040039+ '--reparse-validate',
40+ '--add-include-path', join_paths(meson.current_build_dir()),
41+ '--add-include-path', join_paths(meson.current_source_dir()),
42+ ]
43+else
44+ scanner_command = [
45+ python,
46+ girscanner,
47+ '--output=@OUTPUT@',
48+ '--no-libtool',
Brad Bishopc342db32019-05-15 21:57:59 -040049+ '--quiet',
Brad Bishop19323692019-04-05 15:28:33 -040050+ '--reparse-validate',
51+ '--add-include-path', join_paths(meson.current_build_dir()),
52+ '--add-include-path', join_paths(meson.current_source_dir()),
53+ ]
54+endif
55+
56
57 dep_type = glib_dep.type_name()
58 if dep_type == 'internal'
Brad Bishopc342db32019-05-15 21:57:59 -040059@@ -58,6 +71,12 @@ if dep_type == 'internal'
Brad Bishop19323692019-04-05 15:28:33 -040060 '--extra-library=glib-2.0', '--extra-library=gobject-2.0']
61 endif
62
63+if get_option('enable-gi-cross-wrapper') != ''
64+ scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
65+endif
66+if get_option('enable-gi-ldd-wrapper') != ''
67+ scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
68+endif
69 # Take a glob and print to newlines
70 globber = '''
71 from glob import glob
Brad Bishopc342db32019-05-15 21:57:59 -040072@@ -84,8 +103,8 @@ glib_command = scanner_command + [
Brad Bishop19323692019-04-05 15:28:33 -040073
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')
Brad Bishopc342db32019-05-15 21:57:59 -040083@@ -339,7 +358,7 @@ endforeach
Brad Bishop19323692019-04-05 15:28:33 -040084 if giounix_dep.found()
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
Brad Bishopc342db32019-05-15 21:57:59 -040092@@ -422,15 +441,24 @@ gir_files += custom_target('gir-girepository',
Brad Bishop19323692019-04-05 15:28:33 -040093 )
94
Brad Bishopc342db32019-05-15 21:57:59 -040095 typelibs = []
Brad Bishop19323692019-04-05 15:28:33 -040096+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(),
100+ ]
101+else
102+ gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
103+ '--includedir', meson.current_build_dir(),
104+ '--includedir', meson.current_source_dir(),
105+ ]
106+endif
107+
108 foreach gir : gir_files
Brad Bishopc342db32019-05-15 21:57:59 -0400109 typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(),
Brad Bishop19323692019-04-05 15:28:33 -0400110 input: gir,
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(),
116- ],
117+ command: gircompiler_command,
118 install: true,
119 install_dir: typelibdir,
120 )
121diff --git a/meson.build b/meson.build
Brad Bishopc342db32019-05-15 21:57:59 -0400122index 95bbd2b..f7baefd 100644
Brad Bishop19323692019-04-05 15:28:33 -0400123--- a/meson.build
124+++ b/meson.build
Brad Bishopc342db32019-05-15 21:57:59 -0400125@@ -163,7 +163,9 @@ endif
Brad Bishop19323692019-04-05 15:28:33 -0400126 subdir('girepository')
127 subdir('tools')
128 subdir('giscanner')
129-subdir('gir')
130+if get_option('enable-introspection-data') == true
131+ subdir('gir')
132+endif
133 subdir('examples')
134 subdir('docs')
135 subdir('tests')
136diff --git a/meson_options.txt b/meson_options.txt
Brad Bishopc342db32019-05-15 21:57:59 -0400137index 445a68a..a325511 100644
Brad Bishop19323692019-04-05 15:28:33 -0400138--- a/meson_options.txt
139+++ b/meson_options.txt
140@@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3',
Brad Bishopc342db32019-05-15 21:57:59 -0400141 option('gir_dir_prefix', type: 'string',
Brad Bishop19323692019-04-05 15:28:33 -0400142 description: 'Intermediate prefix for gir installation under ${prefix}'
143 )
144+
145+option('enable-host-gi', type: 'boolean', value : false,
146+ description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
147+)
148+
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)'
151+)
152+
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)'
155+)
156+
157+option('enable-introspection-data', type: 'boolean', value : true,
158+ description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
159+)
160+
161+option('pkgconfig-sysroot-path', type: 'string',
162+ description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'
163+)