Skip to content

Commit 3ea97a2

Browse files
[3.13] gh-146541: Allow building the Android testbed for 32-bit targets (GH-146542) (#148107)
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>
1 parent 38e2470 commit 3ea97a2

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

Android/android.py

Lines changed: 6 additions & 1 deletion
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

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
@@ -647,12 +647,16 @@ def get_platform():
647647
# When Python is running on 32-bit ARM Android on a 64-bit ARM kernel,
648648
# 'os.uname().machine' is 'armv8l'. Such devices run the same userspace
649649
# code as 'armv7l' devices.
650+
# During the build process of the Android testbed when targeting 32-bit ARM,
651+
# '_PYTHON_HOST_PLATFORM' is 'arm-linux-androideabi', so 'machine' becomes
652+
# 'arm'.
650653
machine = {
651-
"x86_64": "x86_64",
652-
"i686": "x86",
653654
"aarch64": "arm64_v8a",
655+
"arm": "armeabi_v7a",
654656
"armv7l": "armeabi_v7a",
655657
"armv8l": "armeabi_v7a",
658+
"i686": "x86",
659+
"x86_64": "x86_64",
656660
}[machine]
657661
else:
658662
# 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
@@ -373,11 +373,12 @@ def test_get_platform(self):
373373
sys.platform = 'android'
374374
get_config_vars()['ANDROID_API_LEVEL'] = 9
375375
for machine, abi in {
376-
'x86_64': 'x86_64',
377-
'i686': 'x86',
378376
'aarch64': 'arm64_v8a',
377+
'arm': 'armeabi_v7a',
379378
'armv7l': 'armeabi_v7a',
380379
'armv8l': 'armeabi_v7a',
380+
'i686': 'x86',
381+
'x86_64': 'x86_64',
381382
}.items():
382383
with self.subTest(machine):
383384
self._set_uname(('Linux', 'localhost', '3.18.91+',
@@ -586,11 +587,12 @@ def test_android_ext_suffix(self):
586587
machine = platform.machine()
587588
suffix = sysconfig.get_config_var('EXT_SUFFIX')
588589
expected_triplet = {
589-
"x86_64": "x86_64-linux-android",
590-
"i686": "i686-linux-android",
591590
"aarch64": "aarch64-linux-android",
591+
"arm": "arm-linux-androideabi",
592592
"armv7l": "arm-linux-androideabi",
593593
"armv8l": "arm-linux-androideabi",
594+
"i686": "i686-linux-android",
595+
"x86_64": "x86_64-linux-android",
594596
}[machine]
595597
self.assertTrue(suffix.endswith(f"-{expected_triplet}.so"),
596598
f"{machine=}, {suffix=}")
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)