()
| 386 | |
| 387 | |
| 388 | def main() -> int: |
| 389 | parser = argparse.ArgumentParser( |
| 390 | description="Native WASM compilation using clang-tool-chain" |
| 391 | ) |
| 392 | parser.add_argument("source", nargs="?", help="Source wrapper .cpp file") |
| 393 | parser.add_argument("--example", help="Example name (e.g., Blink)") |
| 394 | parser.add_argument("-o", "--output", required=True, help="Output .js file") |
| 395 | parser.add_argument( |
| 396 | "--mode", |
| 397 | default="quick", |
| 398 | choices=["debug", "fast_debug", "quick", "release"], |
| 399 | help="Build mode (default: quick)", |
| 400 | ) |
| 401 | parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output") |
| 402 | parser.add_argument( |
| 403 | "--force", action="store_true", help="Force rebuild of all components" |
| 404 | ) |
| 405 | parser.add_argument( |
| 406 | "--unity-chunks", |
| 407 | type=int, |
| 408 | default=0, |
| 409 | metavar="N", |
| 410 | help="Enable unity builds with N chunks (default: 0 = disabled)", |
| 411 | ) |
| 412 | |
| 413 | args = parser.parse_args() |
| 414 | |
| 415 | # Determine source file |
| 416 | if args.example: |
| 417 | # Create wrapper for example |
| 418 | wrapper_file = PROJECT_ROOT / "build" / f"{args.example}_wrapper.cpp" |
| 419 | wrapper_file.parent.mkdir(exist_ok=True) |
| 420 | source_file = create_wrapper_for_example(args.example, wrapper_file) |
| 421 | elif args.source: |
| 422 | source_file = Path(args.source) |
| 423 | if not source_file.exists(): |
| 424 | print(f"Error: Source file not found: {source_file}", file=sys.stderr) |
| 425 | return 1 |
| 426 | else: |
| 427 | parser.error("Either source or --example must be specified") |
| 428 | |
| 429 | output_file = Path(args.output) |
| 430 | |
| 431 | try: |
| 432 | return compile_wasm( |
| 433 | source_file, |
| 434 | output_file, |
| 435 | args.mode, |
| 436 | args.verbose, |
| 437 | args.force, |
| 438 | args.unity_chunks, |
| 439 | ) |
| 440 | except KeyboardInterrupt as ki: |
| 441 | handle_keyboard_interrupt(ki) |
| 442 | raise |
| 443 | print("\n✗ Build interrupted by user") |
| 444 | return 130 |
| 445 |
no test coverage detected