]> code.ossystems Code Review - openembedded-core.git/blob
b0eee1ebe5b6c8c5bb67918ebacde1e3e16e9cfc
[openembedded-core.git] /
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
5
6 Upstream-Status: Pending
7 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
8 ---
9  gir/meson.build   | 59 ++++++++++++++++++++++++++++++++++-------------
10  meson.build       |  4 +++-
11  meson_options.txt | 20 ++++++++++++++++
12  3 files changed, 66 insertions(+), 17 deletions(-)
13
14 diff --git a/gir/meson.build b/gir/meson.build
15 index 607bbc4..c0e221b 100644
16 --- a/gir/meson.build
17 +++ b/gir/meson.build
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)
21  
22 -scanner_command = [
23 -  python,
24 -  girscanner,
25 -  '--output=@OUTPUT@',
26 -  '--no-libtool',
27 -  '--reparse-validate',
28 -  '--add-include-path', join_paths(meson.current_build_dir()),
29 -  '--add-include-path', join_paths(meson.current_source_dir()),
30 -]
31 +if get_option('enable-host-gi')
32 +    scanner_command = [
33 +      'g-ir-scanner',
34 +      '--output=@OUTPUT@',
35 +      '--no-libtool',
36 +      '--reparse-validate',
37 +      '--add-include-path', join_paths(meson.current_build_dir()),
38 +      '--add-include-path', join_paths(meson.current_source_dir()),
39 +    ]
40 +else
41 +    scanner_command = [
42 +      python,
43 +      girscanner,
44 +      '--output=@OUTPUT@',
45 +      '--no-libtool',
46 +      '--reparse-validate',
47 +      '--add-include-path', join_paths(meson.current_build_dir()),
48 +      '--add-include-path', join_paths(meson.current_source_dir()),
49 +    ]
50 +endif
51 +
52  
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']
57  endif
58  
59 +if get_option('enable-gi-cross-wrapper') != ''
60 +  scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
61 +endif
62 +if get_option('enable-gi-ldd-wrapper') != ''
63 +  scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
64 +endif
65  # Take a glob and print to newlines
66  globber = '''
67  from glob import glob
68 @@ -84,8 +102,8 @@ glib_command = scanner_command + [
69  
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',
89    ]
90  )
91  
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(),
96 +    ]
97 +else
98 +    gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
99 +              '--includedir', meson.current_build_dir(),
100 +              '--includedir', meson.current_source_dir(),
101 +    ]
102 +endif
103 +
104  foreach gir : gir_files
105    custom_target('generate-typelib-@0@'.format(gir).underscorify(),
106      input: gir,
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(),
112 -    ],
113 +    command: gircompiler_command,
114      install: true,
115      install_dir: typelibdir,
116    )
117 diff --git a/meson.build b/meson.build
118 index 7ec9532..9e20da5 100644
119 --- a/meson.build
120 +++ b/meson.build
121 @@ -76,7 +76,9 @@ libffi_dep = dependency('libffi',
122  subdir('girepository')
123  subdir('tools')
124  subdir('giscanner')
125 -subdir('gir')
126 +if get_option('enable-introspection-data') == true
127 +    subdir('gir')
128 +endif
129  subdir('examples')
130  subdir('docs')
131  subdir('tests')
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'
139  )
140 +
141 +option('enable-host-gi', type: 'boolean', value : false,
142 +  description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
143 +)
144 +
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)'
147 +)
148 +
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)'
151 +)
152 +
153 +option('enable-introspection-data', type: 'boolean', value : false,
154 +  description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
155 +)
156 +
157 +option('pkgconfig-sysroot-path', type: 'string',
158 +  description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'
159 +)