Build configuration from parsed arguments.
(self, args: argparse.Namespace)
| 291 | return parser |
| 292 | |
| 293 | def _build_config(self, args: argparse.Namespace) -> CompilationConfig: |
| 294 | """Build configuration from parsed arguments.""" |
| 295 | # Resolve boards |
| 296 | boards = self._resolve_boards(args.boards) |
| 297 | |
| 298 | # Determine workflow type (NATIVE for everything except wasm board) |
| 299 | workflow = self._determine_workflow(boards) |
| 300 | |
| 301 | # Resolve examples |
| 302 | examples, skip_filters = self._resolve_examples(args, args.no_filter) |
| 303 | |
| 304 | # Parse other options |
| 305 | defines: list[str] = args.defines.split(",") if args.defines else [] |
| 306 | extra_packages: list[str] = ( |
| 307 | [pkg.strip() for pkg in args.extra_packages.split(",")] |
| 308 | if args.extra_packages |
| 309 | else [] |
| 310 | ) |
| 311 | |
| 312 | # Resolve build backend. Precedence (last wins among explicit flags): |
| 313 | # --fbuild -> fbuild |
| 314 | # --platformio / --pio -> platformio |
| 315 | # --backend=<value> -> <value> (explicit takes precedence over shortcuts |
| 316 | # only if also passed; argparse has no easy "was flag passed" signal |
| 317 | # for choices with a default, so we honor the shortcut if set, else |
| 318 | # the --backend value). |
| 319 | backend = BuildBackend(args.backend) |
| 320 | if getattr(args, "platformio_backend", False): |
| 321 | backend = BuildBackend.PLATFORMIO |
| 322 | if getattr(args, "fbuild_backend", False): |
| 323 | backend = BuildBackend.FBUILD |
| 324 | |
| 325 | return CompilationConfig( |
| 326 | boards=boards, |
| 327 | examples=examples, |
| 328 | workflow=workflow, |
| 329 | defines=defines, |
| 330 | extra_packages=extra_packages, |
| 331 | verbose=args.verbose, |
| 332 | output_path=Path(args.out) if args.out else None, |
| 333 | merged_bin=args.merged_bin, |
| 334 | log_failures=Path(args.log_failures) if args.log_failures else None, |
| 335 | max_failures=args.max_failures if hasattr(args, "max_failures") else None, |
| 336 | wasm_run=args.run, |
| 337 | global_cache_dir=Path(args.global_cache) if args.global_cache else None, |
| 338 | skip_filters=skip_filters, |
| 339 | no_parallel=args.no_parallel, |
| 340 | build_info=Path(args.build_info) |
| 341 | if hasattr(args, "build_info") and args.build_info |
| 342 | else None, |
| 343 | backend=backend, |
| 344 | ) |
| 345 | |
| 346 | def _resolve_boards(self, board_spec: Optional[str]) -> list[Board]: |
| 347 | """Resolve board specification to Board objects. |
no test coverage detected