Skip to content

Commit ab3d37f

Browse files
freakboy3742robertkirkmanmhsmith
authored
[3.14] gh-146541: Allow building the Android testbed for 32-bit targets (GH-146542) (#148064)
Allows building the Android testbed for 32-bit targets, adding the target triplets `arm-linux-androideabi` and `i686-linux-android`. (cherry picked from commit 848bbe9) Co-authored-by: Robert Kirkman <31490854+robertkirkman@users.noreply.github.com> Co-authored-by: Malcolm Smith <smith@chaquo.com>
1 parent f4c9bc8 commit ab3d37f

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.0.19-1",
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
@@ -701,12 +701,16 @@ def get_platform():
701701
# When Python is running on 32-bit ARM Android on a 64-bit ARM kernel,
702702
# 'os.uname().machine' is 'armv8l'. Such devices run the same userspace
703703
# code as 'armv7l' devices.
704+
# During the build process of the Android testbed when targeting 32-bit ARM,
705+
# '_PYTHON_HOST_PLATFORM' is 'arm-linux-androideabi', so 'machine' becomes
706+
# 'arm'.
704707
machine = {
705-
"x86_64": "x86_64",
706-
"i686": "x86",
707708
"aarch64": "arm64_v8a",
709+
"arm": "armeabi_v7a",
708710
"armv7l": "armeabi_v7a",
709711
"armv8l": "armeabi_v7a",
712+
"i686": "x86",
713+
"x86_64": "x86_64",
710714
}[machine]
711715
elif osname == "linux":
712716
# 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
@@ -375,11 +375,12 @@ def test_get_platform(self):
375375
sys.platform = 'android'
376376
get_config_vars()['ANDROID_API_LEVEL'] = 9
377377
for machine, abi in {
378-
'x86_64': 'x86_64',
379-
'i686': 'x86',
380378
'aarch64': 'arm64_v8a',
379+
'arm': 'armeabi_v7a',
381380
'armv7l': 'armeabi_v7a',
382381
'armv8l': 'armeabi_v7a',
382+
'i686': 'x86',
383+
'x86_64': 'x86_64',
383384
}.items():
384385
with self.subTest(machine):
385386
self._set_uname(('Linux', 'localhost', '3.18.91+',
@@ -584,11 +585,12 @@ def test_android_ext_suffix(self):
584585
machine = platform.machine()
585586
suffix = sysconfig.get_config_var('EXT_SUFFIX')
586587
expected_triplet = {
587-
"x86_64": "x86_64-linux-android",
588-
"i686": "i686-linux-android",
589588
"aarch64": "aarch64-linux-android",
589+
"arm": "arm-linux-androideabi",
590590
"armv7l": "arm-linux-androideabi",
591591
"armv8l": "arm-linux-androideabi",
592+
"i686": "i686-linux-android",
593+
"x86_64": "x86_64-linux-android",
592594
}[machine]
593595
self.assertEndsWith(suffix, f"-{expected_triplet}.so")
594596

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)