-
Notifications
You must be signed in to change notification settings - Fork 83
Add support for targeting Android #824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -744,6 +744,35 @@ def __init__( | |||||||||||||||||||||||||
| self._meson_cross_file.write_text(cross_file_data, encoding='utf-8') | ||||||||||||||||||||||||||
| self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file))) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Android may be native-compiled (e.g. with Termux), cross-compiled with manual | ||||||||||||||||||||||||||
| # Meson arguments, or cross-compiled with cibuildwheel, which uses a similar | ||||||||||||||||||||||||||
| # approach to crossenv. In the latter case, we synthesize a cross file to make | ||||||||||||||||||||||||||
| # that work out of the box. | ||||||||||||||||||||||||||
| elif sysconfig.get_platform().startswith('android-') and 'CIBUILDWHEEL' in os.environ: | ||||||||||||||||||||||||||
| cpu = platform.machine() | ||||||||||||||||||||||||||
| cpu_family = 'arm' if cpu.startswith('arm') else 'x86' if cpu.endswith('86') else cpu | ||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have a comment that explains what this normalization does? I find the |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| cross_file_data = textwrap.dedent(f''' | ||||||||||||||||||||||||||
| [host_machine] | ||||||||||||||||||||||||||
| system = 'android' | ||||||||||||||||||||||||||
| subsystem = 'android' | ||||||||||||||||||||||||||
| kernel = 'linux' | ||||||||||||||||||||||||||
| cpu_family = {cpu_family!r} | ||||||||||||||||||||||||||
| cpu = {cpu!r} | ||||||||||||||||||||||||||
| endian = {sys.byteorder!r} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| [properties] | ||||||||||||||||||||||||||
| # cibuildwheel monkey-patches platform.system and platform.machine to | ||||||||||||||||||||||||||
| # simulate running on Android, when it's actually running on Linux or | ||||||||||||||||||||||||||
| # macOS. So the host and build machines will appear to match, but host | ||||||||||||||||||||||||||
| # binaries cannot actually be run on the build machine. As described at | ||||||||||||||||||||||||||
| # https://mesonbuild.com/Cross-compilation.html, we indicate this by | ||||||||||||||||||||||||||
| # setting needs_exe_wrapper = true, but NOT setting exe_wrapper. | ||||||||||||||||||||||||||
|
Comment on lines
+765
to
+770
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly to make things easier for me to understand when I will go back to read this one year from now:
Suggested change
|
||||||||||||||||||||||||||
| needs_exe_wrapper = true | ||||||||||||||||||||||||||
| ''') | ||||||||||||||||||||||||||
| self._meson_cross_file.write_text(cross_file_data, encoding='utf-8') | ||||||||||||||||||||||||||
| self._meson_args['setup'].extend(('--cross-file', os.fspath(self._meson_cross_file))) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Support iOS targets. iOS does not have native build tools and always | ||||||||||||||||||||||||||
| # requires cross compilation: synthesize the appropriate cross file. | ||||||||||||||||||||||||||
| elif sysconfig.get_platform().startswith('ios-'): | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
is more to the point and describes what the following code block is really about.