]> code.ossystems Code Review - openembedded-core.git/blob
639f9c8f61a1773b3080da54baf8a814713533f1
[openembedded-core.git] /
1 From 0417a1bb08745f2bf5310d20b342c2b3b9b212d3 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   | 62 ++++++++++++++++++++++++++++++++++-------------
11  meson.build       |  4 ++-
12  meson_options.txt | 20 +++++++++++++++
13  3 files changed, 68 insertions(+), 18 deletions(-)
14
15 diff --git a/gir/meson.build b/gir/meson.build
16 index c312100..a028033 100644
17 --- a/gir/meson.build
18 +++ b/gir/meson.build
19 @@ -41,16 +41,29 @@ 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 -  '--quiet',
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',
38 +      '--quiet',
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',
49 +      '--quiet',
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'
59 @@ -63,6 +76,12 @@ if dep_type == 'internal'
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
72 @@ -89,8 +108,8 @@ glib_command = scanner_command + [
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')
83 @@ -345,7 +364,7 @@ if giounix_dep.found()
84    dep_type = giounix_dep.type_name()
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
92 @@ -428,15 +447,24 @@ gir_files += custom_target('gir-girepository',
93  )
94  
95  typelibs = []
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
109    typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(),
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
122 index a5e825f..a28490a 100644
123 --- a/meson.build
124 +++ b/meson.build
125 @@ -168,7 +168,9 @@ endif
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
137 index 445a68a..a325511 100644
138 --- a/meson_options.txt
139 +++ b/meson_options.txt
140 @@ -25,3 +25,23 @@ option('python', type: 'string', value: 'python3',
141  option('gir_dir_prefix', type: 'string',
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 +)