@@ -173,8 +173,11 @@ def all_host_triples(platform: str) -> list[str]:
173173 return triples
174174
175175
176- def clean (context : argparse .Namespace , target : str = "all" ) -> None :
176+ def clean (context : argparse .Namespace , target : str | None = None ) -> None :
177177 """The implementation of the "clean" command."""
178+ if target is None :
179+ target = context .host
180+
178181 # If we're explicitly targeting the build, there's no platform or
179182 # distribution artefacts. If we're cleaning tests, we keep all built
180183 # artefacts. Otherwise, the built artefacts must be dirty, so we remove
@@ -377,7 +380,12 @@ def configure_host_python(
377380 with group (f"Downloading dependencies ({ host } )" ):
378381 if not prefix_dir .exists ():
379382 prefix_dir .mkdir ()
380- unpack_deps (context .platform , host , prefix_dir , context .cache_dir )
383+ cache_dir = (
384+ Path (context .cache_dir ).resolve ()
385+ if context .cache_dir
386+ else CROSS_BUILD_DIR / "downloads"
387+ )
388+ unpack_deps (context .platform , host , prefix_dir , cache_dir )
381389 else :
382390 print ("Dependencies already installed" )
383391
@@ -828,7 +836,7 @@ def test(context: argparse.Namespace, host: str | None = None) -> None: # noqa:
828836 + [
829837 "--" ,
830838 "test" ,
831- f"--{ context .ci_mode } -ci" ,
839+ f"--{ context .ci_mode or 'fast' } -ci" ,
832840 "--single-process" ,
833841 "--no-randomize" ,
834842 "--pythoninfo" ,
@@ -895,7 +903,7 @@ def parse_args() -> argparse.Namespace:
895903 configure_build = subcommands .add_parser (
896904 "configure-build" , help = "Run `configure` for the build Python"
897905 )
898- subcommands .add_parser (
906+ make_build = subcommands .add_parser (
899907 "make-build" , help = "Run `make` for the build Python"
900908 )
901909 configure_host = subcommands .add_parser (
@@ -951,6 +959,31 @@ def parse_args() -> argparse.Namespace:
951959 ),
952960 )
953961
962+ # --cross-build-dir argument
963+ for cmd in [
964+ clean ,
965+ configure_build ,
966+ make_build ,
967+ configure_host ,
968+ make_host ,
969+ build ,
970+ package ,
971+ test ,
972+ ci ,
973+ ]:
974+ cmd .add_argument (
975+ "--cross-build-dir" ,
976+ action = "store" ,
977+ default = os .environ .get ("CROSS_BUILD_DIR" ),
978+ dest = "cross_build_dir" ,
979+ type = Path ,
980+ help = (
981+ "Path to the cross-build directory "
982+ f"(default: { CROSS_BUILD_DIR } ). Can also be set "
983+ "with the CROSS_BUILD_DIR environment variable."
984+ ),
985+ )
986+
954987 # --clean option
955988 for cmd in [configure_build , configure_host , build , package , test , ci ]:
956989 cmd .add_argument (
@@ -965,7 +998,7 @@ def parse_args() -> argparse.Namespace:
965998 for cmd in [configure_host , build , ci ]:
966999 cmd .add_argument (
9671000 "--cache-dir" ,
968- default = "./cross-build/downloads" ,
1001+ default = os . environ . get ( "CACHE_DIR" ) ,
9691002 help = "The directory to store cached downloads." ,
9701003 )
9711004
@@ -1032,6 +1065,12 @@ def signal_handler(*args):
10321065
10331066 # Process command line arguments
10341067 context = parse_args ()
1068+
1069+ # Set the CROSS_BUILD_DIR if an argument was provided
1070+ if context .cross_build_dir :
1071+ global CROSS_BUILD_DIR
1072+ CROSS_BUILD_DIR = context .cross_build_dir .resolve ()
1073+
10351074 dispatch : dict [str , Callable ] = {
10361075 "clean" : clean ,
10371076 "configure-build" : configure_build_python ,
0 commit comments