Skip to content

Commit 56db932

Browse files
authored
Add Android configuration (#516)
1 parent 261bfce commit 56db932

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

master/custom/builders.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
Wasm32WasiCrossBuild,
4646
Wasm32WasiDebugBuild,
4747
IOSARM64SimulatorBuild,
48+
AndroidBuild,
4849
)
4950

5051
# A builder can be marked as stable when at least the 10 latest builds are
@@ -172,6 +173,10 @@
172173

173174
# iOS
174175
("iOS ARM64 Simulator", "rkm-arm64-ios-simulator", IOSARM64SimulatorBuild),
176+
177+
# Android
178+
("aarch64 Android", "mhsmith-android-aarch64", AndroidBuild),
179+
("AMD64 Android", "mhsmith-android-x86_64", AndroidBuild),
175180
]
176181

177182

master/custom/factories.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,10 @@ class Wasm32WasiDebugBuild(_Wasm32WasiBuild):
960960
testFlags = ["-u-cpu"]
961961

962962

963+
##############################################################################
964+
################################ IOS BUILDS ################################
965+
##############################################################################
966+
963967
class _IOSSimulatorBuild(UnixBuild):
964968
"""iOS Simulator build.
965969
@@ -1138,3 +1142,71 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
11381142
class IOSARM64SimulatorBuild(_IOSSimulatorBuild):
11391143
"""An ARM64 iOS simulator build."""
11401144
arch = "arm64"
1145+
1146+
1147+
##############################################################################
1148+
############################## ANDROID BUILDS ##############################
1149+
##############################################################################
1150+
1151+
class AndroidBuild(BaseBuild):
1152+
"""Build Python for Android on a Linux or Mac machine, and test it using a
1153+
Gradle-managed emulator. Worker setup instructions:
1154+
1155+
* Install all the usual tools and libraries needed to build Python for the
1156+
worker's own operating system.
1157+
1158+
* Follow the instructions in the Prerequisites section of
1159+
cpython/Android/README.md.
1160+
1161+
* On Linux:
1162+
* Make sure the worker has access to the KVM virtualization interface.
1163+
* Start an X server such as Xvfb, and set the DISPLAY environment variable
1164+
to point at it.
1165+
"""
1166+
1167+
def setup(self, **kwargs):
1168+
android_py = "Android/android.py"
1169+
self.addSteps([
1170+
SetPropertyFromCommand(
1171+
name="Get build triple",
1172+
command=["./config.guess"],
1173+
property="build_triple",
1174+
haltOnFailure=True,
1175+
),
1176+
Configure(
1177+
name="Configure build Python",
1178+
command=[android_py, "configure-build"],
1179+
),
1180+
Compile(
1181+
name="Compile build Python",
1182+
command=[android_py, "make-build"],
1183+
),
1184+
Configure(
1185+
name="Configure host Python",
1186+
command=[android_py, "configure-host", self.host_triple],
1187+
),
1188+
Compile(
1189+
name="Compile host Python",
1190+
command=[android_py, "make-host", self.host_triple],
1191+
),
1192+
Compile(
1193+
name="Build testbed",
1194+
command=[android_py, "build-testbed"],
1195+
),
1196+
Test(
1197+
command=[
1198+
android_py, "test", "--managed", "maxVersion", "--",
1199+
"-W", "-uall",
1200+
],
1201+
timeout=step_timeout(self.test_timeout),
1202+
),
1203+
ShellCommand(
1204+
name="Clean",
1205+
command=[android_py, "clean"],
1206+
),
1207+
])
1208+
1209+
@util.renderer
1210+
def host_triple(props):
1211+
build_triple = props.getProperty("build_triple")
1212+
return build_triple.split("-")[0] + "-linux-android"

master/custom/workers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,16 @@ def get_workers(settings):
302302
not_branches=['3.9', '3.10', '3.11', '3.12'],
303303
parallel_builders=4,
304304
),
305+
cpw(
306+
name="mhsmith-android-aarch64",
307+
tags=['android'],
308+
not_branches=['3.9', '3.10', '3.11', '3.12'],
309+
parallel_builders=1, # All builds use the same emulator and app ID.
310+
),
311+
cpw(
312+
name="mhsmith-android-x86_64",
313+
tags=['android'],
314+
not_branches=['3.9', '3.10', '3.11', '3.12'],
315+
parallel_builders=1, # All builds use the same emulator and app ID.
316+
),
305317
]

0 commit comments

Comments
 (0)