Skip to content

Commit b989526

Browse files
committed
gh-146541: Allow building the Android testbed for 32-bit targets
This allows building the Android testbed for 32-bit targets using the prebuilt 32-bit dependencies that are already available here: https://github.com/beeware/cpython-android-source-deps/releases , adding the target triplets to match them, `arm-linux-androideabi` and `i686-linux-android`. This also adds the `arm` key to the dictionary used to convert the `machine` variable to an Android ABI in `sysconfig.get_platform()`, because when the Android testbed is being cross-compiled, it stores the contents of the first substring of `_PYTHON_HOST_PLATFORM` before the first `-` symbol in the `machine` variable, which the dictionary does not currently handle.
1 parent 1384f02 commit b989526

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

Android/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
TESTBED_DIR = ANDROID_DIR / "testbed"
3535
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
3636

37-
HOSTS = ["aarch64-linux-android", "x86_64-linux-android"]
37+
HOSTS = ["aarch64-linux-android", "x86_64-linux-android", "arm-linux-androideabi", "i686-linux-android"]
3838
APP_ID = "org.python.testbed"
3939
DECODE_ARGS = ("UTF-8", "backslashreplace")
4040

Android/testbed/app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ val inSourceTree = (
1616
val KNOWN_ABIS = mapOf(
1717
"aarch64-linux-android" to "arm64-v8a",
1818
"x86_64-linux-android" to "x86_64",
19+
"arm-linux-androideabi" to "armeabi-v7a",
20+
"i686-linux-android" to "x86",
1921
)
2022

2123
// Discover prefixes.

Lib/sysconfig/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,16 @@ def get_platform():
697697
# When Python is running on 32-bit ARM Android on a 64-bit ARM kernel,
698698
# 'os.uname().machine' is 'armv8l'. Such devices run the same userspace
699699
# code as 'armv7l' devices.
700+
# During the build process of the Android testbed when targeting 32-bit ARM,
701+
# '_PYTHON_HOST_PLATFORM' is 'arm-linux-androideabi', so 'machine' becomes
702+
# 'arm'.
700703
machine = {
701704
"x86_64": "x86_64",
702705
"i686": "x86",
703706
"aarch64": "arm64_v8a",
704707
"armv7l": "armeabi_v7a",
705708
"armv8l": "armeabi_v7a",
709+
"arm": "armeabi_v7a",
706710
}[machine]
707711
elif osname == "linux":
708712
# At least on Linux/Intel, 'machine' is the processor --

Lib/test/test_sysconfig.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def test_get_platform(self):
376376
'aarch64': 'arm64_v8a',
377377
'armv7l': 'armeabi_v7a',
378378
'armv8l': 'armeabi_v7a',
379+
'arm': 'armeabi_v7a',
379380
}.items():
380381
with self.subTest(machine):
381382
self._set_uname(('Linux', 'localhost', '3.18.91+',
@@ -585,6 +586,7 @@ def test_android_ext_suffix(self):
585586
"aarch64": "aarch64-linux-android",
586587
"armv7l": "arm-linux-androideabi",
587588
"armv8l": "arm-linux-androideabi",
589+
"arm": "arm-linux-androideabi",
588590
}[machine]
589591
self.assertEndsWith(suffix, f"-{expected_triplet}.so")
590592

0 commit comments

Comments
 (0)