Skip to content

Commit 301481b

Browse files
committed
Generate Android cross file
1 parent cfcfb35 commit 301481b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

mesonpy/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,27 @@ def __init__(
744744
self._meson_cross_file.write_text(cross_file_data, encoding='utf-8')
745745
self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file)))
746746

747+
# Android requires cross compilation: synthesize the appropriate cross file.
748+
elif sysconfig.get_platform().startswith('android-'):
749+
cross_file_data = textwrap.dedent(f'''
750+
# Binaries are controlled by environment variables, so they don't need
751+
# to be repeated here.
752+
[host_machine]
753+
system = 'android'
754+
subsystem = 'android'
755+
kernel = 'linux'
756+
cpu = {platform.machine()!r}
757+
cpu_family = {platform.machine()!r}
758+
endian = {sys.byteorder!r}
759+
760+
[properties]
761+
# cibuildwheel's cross virtual environment will make Meson believe it's
762+
# running on Android when it's actually running on Linux or macOS.
763+
needs_exe_wrapper = true
764+
''')
765+
self._meson_cross_file.write_text(cross_file_data, encoding='utf-8')
766+
self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file)))
767+
747768
# Support iOS targets. iOS does not have native build tools and always
748769
# requires cross compilation: synthesize the appropriate cross file.
749770
elif sysconfig.get_platform().startswith('ios-'):

0 commit comments

Comments
 (0)