Skip to content

Commit 848bbe9

Browse files
gh-146541: Allow building the Android testbed for 32-bit targets (#146542)
Allows building the Android testbed for 32-bit targets, adding the target triplets `arm-linux-androideabi` and `i686-linux-android`. Co-authored-by: Malcolm Smith <smith@chaquo.com>
1 parent dea4083 commit 848bbe9

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

Android/android.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
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 = [
38+
"aarch64-linux-android",
39+
"arm-linux-androideabi",
40+
"i686-linux-android",
41+
"x86_64-linux-android",
42+
]
3843
APP_ID = "org.python.testbed"
3944
DECODE_ARGS = ("UTF-8", "backslashreplace")
4045

@@ -209,7 +214,7 @@ def unpack_deps(host, prefix_dir):
209214
os.chdir(prefix_dir)
210215
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
211216
for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.5.5-0",
212-
"sqlite-3.50.4-0", "xz-5.4.6-1", "zstd-1.5.7-1"]:
217+
"sqlite-3.50.4-0", "xz-5.4.6-1", "zstd-1.5.7-2"]:
213218
filename = f"{name_ver}-{host}.tar.gz"
214219
download(f"{deps_url}/{name_ver}/{filename}")
215220
shutil.unpack_archive(filename)

Android/testbed/app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ val inSourceTree = (
1515

1616
val KNOWN_ABIS = mapOf(
1717
"aarch64-linux-android" to "arm64-v8a",
18+
"arm-linux-androideabi" to "armeabi-v7a",
19+
"i686-linux-android" to "x86",
1820
"x86_64-linux-android" to "x86_64",
1921
)
2022

Lib/sysconfig/__init__.py

Lines changed: 6 additions & 2 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 = {
701-
"x86_64": "x86_64",
702-
"i686": "x86",
703704
"aarch64": "arm64_v8a",
705+
"arm": "armeabi_v7a",
704706
"armv7l": "armeabi_v7a",
705707
"armv8l": "armeabi_v7a",
708+
"i686": "x86",
709+
"x86_64": "x86_64",
706710
}[machine]
707711
elif osname == "linux":
708712
# At least on Linux/Intel, 'machine' is the processor --

Lib/test/test_sysconfig.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,12 @@ def test_get_platform(self):
371371
sys.platform = 'android'
372372
get_config_vars()['ANDROID_API_LEVEL'] = 9
373373
for machine, abi in {
374-
'x86_64': 'x86_64',
375-
'i686': 'x86',
376374
'aarch64': 'arm64_v8a',
375+
'arm': 'armeabi_v7a',
377376
'armv7l': 'armeabi_v7a',
378377
'armv8l': 'armeabi_v7a',
378+
'i686': 'x86',
379+
'x86_64': 'x86_64',
379380
}.items():
380381
with self.subTest(machine):
381382
self._set_uname(('Linux', 'localhost', '3.18.91+',
@@ -580,11 +581,12 @@ def test_android_ext_suffix(self):
580581
machine = platform.machine()
581582
suffix = sysconfig.get_config_var('EXT_SUFFIX')
582583
expected_triplet = {
583-
"x86_64": "x86_64-linux-android",
584-
"i686": "i686-linux-android",
585584
"aarch64": "aarch64-linux-android",
585+
"arm": "arm-linux-androideabi",
586586
"armv7l": "arm-linux-androideabi",
587587
"armv8l": "arm-linux-androideabi",
588+
"i686": "i686-linux-android",
589+
"x86_64": "x86_64-linux-android",
588590
}[machine]
589591
self.assertEndsWith(suffix, f"-{expected_triplet}.so")
590592

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The Android testbed can now be built for 32-bit ARM and x86 targets.

0 commit comments

Comments
 (0)