Main function.
()
| 105 | |
| 106 | |
| 107 | def main() -> int: |
| 108 | """Main function.""" |
| 109 | # WASM fast path: bypass full argument parser + heavy imports (~150ms saved) |
| 110 | wasm_rc = _wasm_fast_path() |
| 111 | if wasm_rc is not None: |
| 112 | return wasm_rc |
| 113 | |
| 114 | # Non-WASM path: load stdlib + heavy imports (~25ms + ~350ms) |
| 115 | import time |
| 116 | from pathlib import Path |
| 117 | from typing import Optional |
| 118 | |
| 119 | from ci.util.global_interrupt_handler import install_signal_handler |
| 120 | |
| 121 | install_signal_handler() |
| 122 | |
| 123 | # Parse arguments using new CompilationArgumentParser |
| 124 | from ci.compiler.argument_parser import CompilationArgumentParser, WorkflowType |
| 125 | |
| 126 | # Compilation Docker has been decommissioned (#2812). Project root is |
| 127 | # always derived from this file's location. |
| 128 | project_root = Path(__file__).parent.parent.absolute() |
| 129 | parser = CompilationArgumentParser(project_root) |
| 130 | |
| 131 | # First check if --supported-boards was requested before full parsing |
| 132 | if "--supported-boards" in sys.argv: |
| 133 | from ci.compiler.board_example_utils import get_default_boards |
| 134 | |
| 135 | print(",".join(get_default_boards())) |
| 136 | return 0 |
| 137 | |
| 138 | config = parser.parse() |
| 139 | |
| 140 | # Handle verbose mode |
| 141 | if config.verbose: |
| 142 | os.environ["VERBOSE"] = "1" |
| 143 | |
| 144 | # Handle default boards if none specified |
| 145 | if not config.boards: |
| 146 | from ci.boards import Board, create_board |
| 147 | from ci.compiler.board_example_utils import get_default_boards |
| 148 | |
| 149 | board_names = get_default_boards() |
| 150 | boards: list[Board] = [] |
| 151 | for board_name in board_names: |
| 152 | try: |
| 153 | board = create_board(board_name, no_project_options=False) |
| 154 | boards.append(board) |
| 155 | except KeyboardInterrupt as ki: |
| 156 | from ci.util.global_interrupt_handler import handle_keyboard_interrupt |
| 157 | |
| 158 | handle_keyboard_interrupt(ki) |
| 159 | raise |
| 160 | except Exception as e: |
| 161 | print(f"ERROR: Failed to get board '{board_name}': {e}") |
| 162 | return 1 |
| 163 | # Create new config with default boards |
| 164 | from ci.compiler.argument_parser import CompilationConfig |
no test coverage detected