Skip to content

Commit c3075aa

Browse files
authored
Merge branch 'main' into config-file
2 parents b16e08f + 58e1c7a commit c3075aa

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

Tools/wasm/wasi/__main__.py

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -390,18 +390,6 @@ def make_wasi_python(context, working_dir):
390390
)
391391

392392

393-
def build_all(context):
394-
"""Build everything."""
395-
steps = [
396-
configure_build_python,
397-
make_build_python,
398-
configure_wasi_python,
399-
make_wasi_python,
400-
]
401-
for step in steps:
402-
step(context)
403-
404-
405393
def clean_contents(context):
406394
"""Delete all files created by this script."""
407395
if CROSS_BUILD_DIR.exists():
@@ -413,6 +401,16 @@ def clean_contents(context):
413401
log("🧹", f"Deleting generated {LOCAL_SETUP} ...")
414402

415403

404+
def build_steps(*steps):
405+
"""Construct a command from other steps."""
406+
407+
def builder(context):
408+
for step in steps:
409+
step(context)
410+
411+
return builder
412+
413+
416414
def main():
417415
with (HERE / "config.toml").open("rb") as file:
418416
config = tomllib.load(file)
@@ -444,6 +442,9 @@ def main():
444442
make_build = subcommands.add_parser(
445443
"make-build-python", help="Run `make` for the build Python"
446444
)
445+
build_python = subcommands.add_parser(
446+
"build-python", help="Build the build Python"
447+
)
447448
configure_host = subcommands.add_parser(
448449
"configure-host",
449450
help="Run `configure` for the "
@@ -454,15 +455,20 @@ def main():
454455
make_host = subcommands.add_parser(
455456
"make-host", help="Run `make` for the host/WASI"
456457
)
458+
build_host = subcommands.add_parser(
459+
"build-host", help="Build the host/WASI Python"
460+
)
457461
subcommands.add_parser(
458462
"clean", help="Delete files and directories created by this script"
459463
)
460464
for subcommand in (
461465
build,
462466
configure_build,
463467
make_build,
468+
build_python,
464469
configure_host,
465470
make_host,
471+
build_host,
466472
):
467473
subcommand.add_argument(
468474
"--quiet",
@@ -477,19 +483,30 @@ def main():
477483
default=default_logdir,
478484
help=f"Directory to store log files; defaults to {default_logdir}",
479485
)
480-
for subcommand in configure_build, configure_host:
486+
for subcommand in (
487+
configure_build,
488+
configure_host,
489+
build_python,
490+
build_host,
491+
):
481492
subcommand.add_argument(
482493
"--clean",
483494
action="store_true",
484495
default=False,
485496
dest="clean",
486497
help="Delete any relevant directories before building",
487498
)
488-
for subcommand in build, configure_build, configure_host:
499+
for subcommand in (
500+
build,
501+
configure_build,
502+
configure_host,
503+
build_python,
504+
build_host,
505+
):
489506
subcommand.add_argument(
490507
"args", nargs="*", help="Extra arguments to pass to `configure`"
491508
)
492-
for subcommand in build, configure_host:
509+
for subcommand in build, configure_host, build_host:
493510
subcommand.add_argument(
494511
"--wasi-sdk",
495512
type=pathlib.Path,
@@ -505,7 +522,7 @@ def main():
505522
help="Command template for running the WASI host; defaults to "
506523
f"`{default_host_runner}`",
507524
)
508-
for subcommand in build, configure_host, make_host:
525+
for subcommand in build, configure_host, make_host, build_host:
509526
subcommand.add_argument(
510527
"--host-triple",
511528
action="store",
@@ -517,12 +534,17 @@ def main():
517534
context = parser.parse_args()
518535
context.init_dir = pathlib.Path().absolute()
519536

537+
build_build_python = build_steps(configure_build_python, make_build_python)
538+
build_wasi_python = build_steps(configure_wasi_python, make_wasi_python)
539+
520540
dispatch = {
521541
"configure-build-python": configure_build_python,
522542
"make-build-python": make_build_python,
543+
"build-python": build_build_python,
523544
"configure-host": configure_wasi_python,
524545
"make-host": make_wasi_python,
525-
"build": build_all,
546+
"build-host": build_wasi_python,
547+
"build": build_steps(build_build_python, build_wasi_python),
526548
"clean": clean_contents,
527549
}
528550
dispatch[context.subcommand](context)

0 commit comments

Comments
 (0)