Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | From 2b3bce1526b538dc2c7fa223eaf9808858aa1b06 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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 |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 8 | |
| 9 | --- |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 10 | gir/meson.build | 62 ++++++++++++++++++++++++++++++++++------------- |
| 11 | meson.build | 4 ++- |
| 12 | meson_options.txt | 20 +++++++++++++++ |
| 13 | 3 files changed, 68 insertions(+), 18 deletions(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 14 | |
| 15 | diff --git a/gir/meson.build b/gir/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 16 | index 85ae575..327c134 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 17 | --- a/gir/meson.build |
| 18 | +++ b/gir/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 19 | @@ -36,16 +36,29 @@ gir_files = [ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 20 | 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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 28 | - '--quiet', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | - '--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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 38 | + '--quiet', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 39 | + '--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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 49 | + '--quiet', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 50 | + '--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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 59 | @@ -58,6 +71,12 @@ if dep_type == 'internal' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 60 | '--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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 72 | @@ -84,8 +103,8 @@ glib_command = scanner_command + [ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 73 | |
| 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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 83 | @@ -339,7 +358,7 @@ endforeach |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 84 | 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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 92 | @@ -422,15 +441,24 @@ gir_files += custom_target('gir-girepository', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 93 | ) |
| 94 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 95 | typelibs = [] |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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(), |
| 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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 109 | typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(), |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 110 | 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 | ) |
| 121 | diff --git a/meson.build b/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 122 | index 95bbd2b..f7baefd 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 123 | --- a/meson.build |
| 124 | +++ b/meson.build |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 125 | @@ -163,7 +163,9 @@ endif |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 126 | 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') |
| 136 | diff --git a/meson_options.txt b/meson_options.txt |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 137 | index 445a68a..a325511 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 138 | --- a/meson_options.txt |
| 139 | +++ b/meson_options.txt |
| 140 | @@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3', |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 141 | option('gir_dir_prefix', type: 'string', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 142 | 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 | +) |