@@ -393,17 +393,6 @@ 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-
407396# Work around a bug involving sys.exit and TaskGroups
408397# (https://github.com/python/cpython/issues/101515).
409398def exit (* args ):
@@ -645,6 +634,10 @@ async def gradle_task(context):
645634 task_prefix = "connected"
646635 env ["ANDROID_SERIAL" ] = context .connected
647636
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+
648641 if context .ci_mode :
649642 context .args [0 :0 ] = [
650643 # See _add_ci_python_opts in libregrtest/main.py.
@@ -872,6 +865,18 @@ def parse_args():
872865
873866 def add_parser (* args , ** kwargs ):
874867 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+ )
875880 parser .add_argument (
876881 "-v" , "--verbose" , action = "count" , default = 0 ,
877882 help = "Show verbose output. Use twice to be even more verbose." )
@@ -884,7 +889,7 @@ def add_parser(*args, **kwargs):
884889 )
885890 configure_build = add_parser (
886891 "configure-build" , help = "Run `configure` for the build Python" )
887- make_build = add_parser (
892+ add_parser (
888893 "make-build" , help = "Run `make` for the build Python" )
889894 configure_host = add_parser (
890895 "configure-host" , help = "Run `configure` for Android" )
@@ -896,38 +901,12 @@ def add_parser(*args, **kwargs):
896901 help = "Delete build directories for the selected target"
897902 )
898903
899- add_parser ("build-testbed" , help = "Build the testbed app" )
900904 test = add_parser ("test" , help = "Run the testbed app" )
901905 package = add_parser ("package" , help = "Make a release package" )
902906 ci = add_parser ("ci" , help = "Run build, package and test" )
903907 env = add_parser ("env" , help = "Print environment variables" )
904908
905909 # 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-
931910 # --cache-dir option
932911 for cmd in [configure_host , build , ci ]:
933912 cmd .add_argument (
@@ -1032,7 +1011,6 @@ def main():
10321011 "make-host" : make_host_python ,
10331012 "build" : build_targets ,
10341013 "clean" : clean_targets ,
1035- "build-testbed" : build_testbed ,
10361014 "test" : run_testbed ,
10371015 "package" : package ,
10381016 "ci" : ci ,
0 commit comments