@@ -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 # Timeout handling requires subprocesses; explicitly setting
@@ -894,7 +902,7 @@ def parse_args() -> argparse.Namespace:
894902 configure_build = subcommands.add_parser(
895903 "configure-build", help="Run `configure` for the build Python"
896904 )
897- subcommands .add_parser (
905+ make_build = subcommands.add_parser(
898906 "make-build", help="Run `make` for the build Python"
899907 )
900908 configure_host = subcommands.add_parser(
@@ -950,6 +958,31 @@ def parse_args() -> argparse.Namespace:
950958 ),
951959 )
952960
961+ # --cross-build-dir argument
962+ for cmd in [
963+ clean,
964+ configure_build,
965+ make_build,
966+ configure_host,
967+ make_host,
968+ build,
969+ package,
970+ test,
971+ ci,
972+ ]:
973+ cmd.add_argument(
974+ "--cross-build-dir",
975+ action="store",
976+ default=os.environ.get("CROSS_BUILD_DIR"),
977+ dest="cross_build_dir",
978+ type=Path,
979+ help=(
980+ "Path to the cross-build directory "
981+ f"(default: {CROSS_BUILD_DIR}). Can also be set "
982+ "with the CROSS_BUILD_DIR environment variable."
983+ ),
984+ )
985+
953986 # --clean option
954987 for cmd in [configure_build, configure_host, build, package, test, ci]:
955988 cmd.add_argument(
@@ -964,7 +997,7 @@ def parse_args() -> argparse.Namespace:
964997 for cmd in [configure_host, build, ci]:
965998 cmd.add_argument(
966999 "--cache-dir",
967- default = "./cross-build/downloads" ,
1000+ default=os.environ.get("CACHE_DIR") ,
9681001 help="The directory to store cached downloads.",
9691002 )
9701003
@@ -1031,6 +1064,12 @@ def signal_handler(*args):
10311064
10321065 # Process command line arguments
10331066 context = parse_args()
1067+
1068+ # Set the CROSS_BUILD_DIR if an argument was provided
1069+ if context.cross_build_dir:
1070+ global CROSS_BUILD_DIR
1071+ CROSS_BUILD_DIR = context.cross_build_dir.resolve()
1072+
10341073 dispatch: dict[str, Callable] = {
10351074 "clean": clean,
10361075 "configure-build": configure_build_python,
0 commit comments