Immutable compilation configuration with validation.
| 27 | |
| 28 | @dataclass(frozen=True) |
| 29 | class CompilationConfig: |
| 30 | """Immutable compilation configuration with validation.""" |
| 31 | |
| 32 | # Core configuration |
| 33 | boards: list[Board] |
| 34 | examples: list[str] |
| 35 | workflow: WorkflowType |
| 36 | |
| 37 | # Build options |
| 38 | defines: list[str] = field(default_factory=lambda: []) |
| 39 | extra_packages: list[str] = field(default_factory=lambda: []) |
| 40 | verbose: bool = False |
| 41 | # Output options |
| 42 | output_path: Optional[Path] = None |
| 43 | merged_bin: bool = False |
| 44 | log_failures: Optional[Path] = None |
| 45 | max_failures: Optional[int] = None |
| 46 | |
| 47 | # WASM options |
| 48 | wasm_run: bool = False |
| 49 | |
| 50 | # Advanced options |
| 51 | global_cache_dir: Optional[Path] = None |
| 52 | skip_filters: bool = ( |
| 53 | False # True to skip @filter directives (override platform/memory constraints) |
| 54 | ) |
| 55 | no_parallel: bool = False # Disable parallel compilation (currently a no-op) |
| 56 | |
| 57 | # Info options |
| 58 | build_info: Optional[Path] = None # Output file path for build info JSON |
| 59 | |
| 60 | # Build backend selection (default fbuild; --backend=platformio forces `pio run`) |
| 61 | backend: BuildBackend = BuildBackend.FBUILD |
| 62 | |
| 63 | def validate(self) -> list[str]: |
| 64 | """Validate configuration and return list of error messages.""" |
| 65 | errors: list[str] = [] |
| 66 | |
| 67 | # Validate merged-bin requirements |
| 68 | if self.merged_bin: |
| 69 | if len(self.examples) != 1: |
| 70 | errors.append( |
| 71 | f"--merged-bin requires exactly one sketch, got {len(self.examples)}" |
| 72 | ) |
| 73 | if len(self.boards) != 1: |
| 74 | errors.append( |
| 75 | f"--merged-bin requires exactly one board, got {len(self.boards)}" |
| 76 | ) |
| 77 | if self.boards and not self.boards[0].board_name.startswith("esp"): |
| 78 | errors.append( |
| 79 | f"--merged-bin only supports ESP32/ESP8266, got {self.boards[0].board_name}" |
| 80 | ) |
| 81 | |
| 82 | # Validate output path requirements |
| 83 | if self.output_path: |
| 84 | if len(self.examples) != 1: |
| 85 | errors.append( |
| 86 | f"-o/--out requires exactly one sketch, got {len(self.examples)}" |
no outgoing calls
no test coverage detected