@@ -393,6 +393,17 @@ def setup_testbed():
393393 os .chmod (out_path , 0o755 )
394394
395395
396+ # run_testbed will build the app automatically, but it's useful to have this as
397+ # a separate command to allow running the app outside of this script.
398+ def build_testbed (context ):
399+ setup_sdk ()
400+ setup_testbed ()
401+ run (
402+ [gradlew , "--console" , "plain" , "packageDebug" , "packageDebugAndroidTest" ],
403+ cwd = TESTBED_DIR ,
404+ )
405+
406+
396407# Work around a bug involving sys.exit and TaskGroups
397408# (https://github.com/python/cpython/issues/101515).
398409def exit (* args ):
@@ -634,10 +645,6 @@ async def gradle_task(context):
634645 task_prefix = "connected"
635646 env ["ANDROID_SERIAL" ] = context .connected
636647
637- # Ensure that CROSS_BUILD_DIR is in the Gradle environment, regardless
638- # of whether it was set by environment variable or `--cross-build-dir`.
639- env ["CROSS_BUILD_DIR" ] = CROSS_BUILD_DIR
640-
641648 if context .ci_mode :
642649 context .args [0 :0 ] = [
643650 # See _add_ci_python_opts in libregrtest/main.py.
@@ -865,18 +872,6 @@ def parse_args():
865872
866873 def add_parser (* args , ** kwargs ):
867874 parser = subcommands .add_parser (* args , ** kwargs )
868- parser .add_argument (
869- "--cross-build-dir" ,
870- action = "store" ,
871- default = os .environ .get ("CROSS_BUILD_DIR" ),
872- dest = "cross_build_dir" ,
873- type = Path ,
874- help = (
875- "Path to the cross-build directory "
876- f"(default: { CROSS_BUILD_DIR } ). Can also be set "
877- "with the CROSS_BUILD_DIR environment variable."
878- ),
879- )
880875 parser .add_argument (
881876 "-v" , "--verbose" , action = "count" , default = 0 ,
882877 help = "Show verbose output. Use twice to be even more verbose." )
@@ -889,7 +884,7 @@ def add_parser(*args, **kwargs):
889884 )
890885 configure_build = add_parser (
891886 "configure-build" , help = "Run `configure` for the build Python" )
892- add_parser (
887+ make_build = add_parser (
893888 "make-build" , help = "Run `make` for the build Python" )
894889 configure_host = add_parser (
895890 "configure-host" , help = "Run `configure` for Android" )
@@ -901,12 +896,38 @@ def add_parser(*args, **kwargs):
901896 help = "Delete build directories for the selected target"
902897 )
903898
899+ add_parser ("build-testbed" , help = "Build the testbed app" )
904900 test = add_parser ("test" , help = "Run the testbed app" )
905901 package = add_parser ("package" , help = "Make a release package" )
906902 ci = add_parser ("ci" , help = "Run build, package and test" )
907903 env = add_parser ("env" , help = "Print environment variables" )
908904
909905 # Common arguments
906+ # --cross-build-dir argument
907+ for cmd in [
908+ clean ,
909+ configure_build ,
910+ make_build ,
911+ configure_host ,
912+ make_host ,
913+ build ,
914+ package ,
915+ test ,
916+ ci ,
917+ ]:
918+ cmd .add_argument (
919+ "--cross-build-dir" ,
920+ action = "store" ,
921+ default = os .environ .get ("CROSS_BUILD_DIR" ),
922+ dest = "cross_build_dir" ,
923+ type = Path ,
924+ help = (
925+ "Path to the cross-build directory "
926+ f"(default: { CROSS_BUILD_DIR } ). Can also be set "
927+ "with the CROSS_BUILD_DIR environment variable."
928+ ),
929+ )
930+
910931 # --cache-dir option
911932 for cmd in [configure_host , build , ci ]:
912933 cmd .add_argument (
@@ -1011,6 +1032,7 @@ def main():
10111032 "make-host" : make_host_python ,
10121033 "build" : build_targets ,
10131034 "clean" : clean_targets ,
1035+ "build-testbed" : build_testbed ,
10141036 "test" : run_testbed ,
10151037 "package" : package ,
10161038 "ci" : ci ,
0 commit comments