()
| 209 | |
| 210 | |
| 211 | def main() -> int: |
| 212 | parser = argparse.ArgumentParser( |
| 213 | description="Generate unity build files for WASM compilation" |
| 214 | ) |
| 215 | parser.add_argument( |
| 216 | "--chunks", |
| 217 | type=int, |
| 218 | default=10, |
| 219 | help="Number of unity chunks to create (default: 10)", |
| 220 | ) |
| 221 | parser.add_argument( |
| 222 | "--output", |
| 223 | type=Path, |
| 224 | default=PROJECT_ROOT / "build" / "wasm" / "unity", |
| 225 | help="Output directory for unity files (default: build/wasm/unity)", |
| 226 | ) |
| 227 | parser.add_argument( |
| 228 | "--list", |
| 229 | action="store_true", |
| 230 | help="List unity groups without generating files", |
| 231 | ) |
| 232 | parser.add_argument( |
| 233 | "-v", |
| 234 | "--verbose", |
| 235 | action="store_true", |
| 236 | help="Verbose output", |
| 237 | ) |
| 238 | |
| 239 | args = parser.parse_args() |
| 240 | |
| 241 | try: |
| 242 | if args.list: |
| 243 | list_unity_groups(args.chunks) |
| 244 | return 0 |
| 245 | |
| 246 | unity_files, metadata = generate_unity_builds( |
| 247 | args.chunks, |
| 248 | args.output, |
| 249 | args.verbose, |
| 250 | ) |
| 251 | |
| 252 | # Write metadata |
| 253 | metadata_path = args.output / "unity_metadata.json" |
| 254 | with open(metadata_path, "w") as f: |
| 255 | json.dump(metadata, f, indent=2) |
| 256 | |
| 257 | print(f"✓ Generated {len(unity_files)} unity build files") |
| 258 | print(f" Output: {args.output}") |
| 259 | print(f" Chunks: {metadata['num_chunks']}") |
| 260 | print(f" Sources: {metadata['num_sources']}") |
| 261 | print(f" Metadata: {metadata_path}") |
| 262 | |
| 263 | return 0 |
| 264 | |
| 265 | except KeyboardInterrupt as ki: |
| 266 | handle_keyboard_interrupt(ki) |
| 267 | raise |
| 268 | print("\n✗ Interrupted by user") |
no test coverage detected