Skip to content

Commit 6a12b36

Browse files
mhsmithdnicolodi
andauthored
Apply suggestions from code review
Co-authored-by: Daniele Nicolodi <daniele@grinta.net>
1 parent 84e9f2f commit 6a12b36

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

mesonpy/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,9 @@ 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 may be native-compiled (e.g. with Termux), cross-compiled with manual
748-
# Meson arguments, or cross-compiled with cibuildwheel, which uses a similar
749-
# approach to crossenv. In the latter case, we synthesize a cross file to make
750-
# that work out of the box.
747+
# Simplify cross-compilation for Android with cibuildwheel: detect the
748+
# cross-compilation environment set up by cibuildwheel and synthesize an
749+
# appropriate cross file.
751750
elif sysconfig.get_platform().startswith('android-') and 'CIBUILDWHEEL' in os.environ:
752751
cpu = platform.machine()
753752
cpu_family = 'arm' if cpu.startswith('arm') else 'x86' if cpu.endswith('86') else cpu
@@ -762,12 +761,12 @@ def __init__(
762761
endian = {sys.byteorder!r}
763762
764763
[properties]
765-
# cibuildwheel monkey-patches platform.system and platform.machine to
766-
# simulate running on Android, when it's actually running on Linux or
767-
# macOS. So the host and build machines will appear to match, but host
768-
# binaries cannot actually be run on the build machine. As described at
769-
# https://mesonbuild.com/Cross-compilation.html, we indicate this by
770-
# setting needs_exe_wrapper = true, but NOT setting exe_wrapper.
764+
# Due to Python lacking proper cross-compilation support, for the build
765+
# to produce the correct wheel tags when cross-compiling for Android,
766+
# cibuildwheel monkey-patches platform.system() and platform.machine()
767+
# to simulate running on Android. This makes Meson believe that host and
768+
# build machines match and thus that host binaries can be run on the build
769+
# machine, when this is not actually the case. Override the auto-detection.
771770
needs_exe_wrapper = true
772771
''')
773772
self._meson_cross_file.write_text(cross_file_data, encoding='utf-8')

0 commit comments

Comments
 (0)