]> code.ossystems Code Review - openembedded-core.git/blob
80c9e71ad57c27202824c17460930b7277bce5eb
[openembedded-core.git] /
1 From ea25a5a755bc839d5b504aac207f860ae68109bc 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 ---
10  gir/meson.build   | 59 ++++++++++++++++++++++++++++++++++-------------
11  meson.build       |  4 +++-
12  meson_options.txt | 20 ++++++++++++++++
13  3 files changed, 66 insertions(+), 17 deletions(-)
14
15 diff --git a/gir/meson.build b/gir/meson.build
16 index 1cb514a..f873068 100644
17 --- a/gir/meson.build
18 +++ b/gir/meson.build
19 @@ -36,15 +36,27 @@ gir_files = [
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',
28 -  '--reparse-validate',
29 -  '--add-include-path', join_paths(meson.current_build_dir()),
30 -  '--add-include-path', join_paths(meson.current_source_dir()),
31 -]
32 +if get_option('enable-host-gi')
33 +    scanner_command = [
34 +      'g-ir-scanner',
35 +      '--output=@OUTPUT@',
36 +      '--no-libtool',
37 +      '--reparse-validate',
38 +      '--add-include-path', join_paths(meson.current_build_dir()),
39 +      '--add-include-path', join_paths(meson.current_source_dir()),
40 +    ]
41 +else
42 +    scanner_command = [
43 +      python,
44 +      girscanner,
45 +      '--output=@OUTPUT@',
46 +      '--no-libtool',
47 +      '--reparse-validate',
48 +      '--add-include-path', join_paths(meson.current_build_dir()),
49 +      '--add-include-path', join_paths(meson.current_source_dir()),
50 +    ]
51 +endif
52 +
53  
54  dep_type = glib_dep.type_name()
55  if dep_type == 'internal'
56 @@ -57,6 +69,12 @@ if dep_type == 'internal'
57                        '--extra-library=glib-2.0', '--extra-library=gobject-2.0']
58  endif
59  
60 +if get_option('enable-gi-cross-wrapper') != ''
61 +  scanner_command += ['--use-binary-wrapper=' + get_option('enable-gi-cross-wrapper')]
62 +endif
63 +if get_option('enable-gi-ldd-wrapper') != ''
64 +  scanner_command += ['--use-ldd-wrapper=' + get_option('enable-gi-ldd-wrapper')]
65 +endif
66  # Take a glob and print to newlines
67  globber = '''
68  from glob import glob
69 @@ -83,8 +101,8 @@ glib_command = scanner_command + [
70  
71  if dep_type == 'pkgconfig'
72    glib_command += ['--external-library', '--pkg=glib-2.0']
73 -  glib_libdir = glib_dep.get_pkgconfig_variable('libdir')
74 -  glib_incdir = join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
75 +  glib_libdir = get_option('pkgconfig-sysroot-path') + glib_dep.get_pkgconfig_variable('libdir')
76 +  glib_incdir = get_option('pkgconfig-sysroot-path') + join_paths(glib_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
77    glib_libincdir = join_paths(glib_libdir, 'glib-2.0', 'include')
78    glib_files += join_paths(glib_incdir, 'gobject', 'glib-types.h')
79    glib_files += join_paths(glib_libincdir, 'glibconfig.h')
80 @@ -338,7 +356,7 @@ endforeach
81  if giounix_dep.found()
82    if dep_type == 'pkgconfig'
83      gio_command += ['--pkg=gio-unix-2.0']
84 -    giounix_includedir = join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
85 +    giounix_includedir = get_option('pkgconfig-sysroot-path') + join_paths(giounix_dep.get_pkgconfig_variable('includedir'), 'gio-unix-2.0')
86      # Get the installed gio-unix header list
87      ret = run_command(python, '-c', globber.format(join_paths(giounix_includedir, 'gio', '*.h')))
88      if ret.returncode() != 0
89 @@ -416,15 +434,24 @@ gir_files += custom_target('gir-girepository',
90    ]
91  )
92  
93 +if get_option('enable-gi-cross-wrapper') != ''
94 +    gircompiler_command = [get_option('enable-gi-cross-wrapper'), gircompiler.full_path(), '-o', '@OUTPUT@', '@INPUT@',
95 +              '--includedir', meson.current_build_dir(),
96 +              '--includedir', meson.current_source_dir(),
97 +    ]
98 +else
99 +    gircompiler_command = [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
100 +              '--includedir', meson.current_build_dir(),
101 +              '--includedir', meson.current_source_dir(),
102 +    ]
103 +endif
104 +
105  foreach gir : gir_files
106    custom_target('generate-typelib-@0@'.format(gir).underscorify(),
107      input: gir,
108      output: '@BASENAME@.typelib',
109      depends: [gobject_gir, ],
110 -    command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@',
111 -              '--includedir', meson.current_build_dir(),
112 -              '--includedir', meson.current_source_dir(),
113 -    ],
114 +    command: gircompiler_command,
115      install: true,
116      install_dir: typelibdir,
117    )
118 diff --git a/meson.build b/meson.build
119 index 17acd82..e0bb495 100644
120 --- a/meson.build
121 +++ b/meson.build
122 @@ -81,7 +81,9 @@ libffi_dep = dependency('libffi',
123  subdir('girepository')
124  subdir('tools')
125  subdir('giscanner')
126 -subdir('gir')
127 +if get_option('enable-introspection-data') == true
128 +    subdir('gir')
129 +endif
130  subdir('examples')
131  subdir('docs')
132  subdir('tests')
133 diff --git a/meson_options.txt b/meson_options.txt
134 index ee6958d..b168142 100644
135 --- a/meson_options.txt
136 +++ b/meson_options.txt
137 @@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3',
138  option('gir-dir-prefix', type: 'string',
139    description: 'Intermediate prefix for gir installation under ${prefix}'
140  )
141 +
142 +option('enable-host-gi', type: 'boolean', value : false,
143 +  description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)'
144 +)
145 +
146 +option('enable-gi-cross-wrapper', type: 'string',
147 +  description: 'Use a wrapper to run gicompiler and binaries produced by giscanner (useful when cross-compiling)'
148 +)
149 +
150 +option('enable-gi-ldd-wrapper', type: 'string',
151 +  description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
152 +)
153 +
154 +option('enable-introspection-data', type: 'boolean', value : true,
155 +  description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
156 +)
157 +
158 +option('pkgconfig-sysroot-path', type: 'string',
159 +  description: 'Specify a sysroot path to prepend to pkgconfig output (useful when cross-compiling)'
160 +)