Apply board-specific build configuration from Board class.
(
board: "Board",
platformio_ini_path: Path,
example: str,
paths: "FastLEDPaths",
additional_defines: Optional[list[str]] = None,
additional_include_dirs: Optional[list[str]] = None,
additional_libs: Optional[list[str]] = None,
)
| 273 | |
| 274 | |
| 275 | def apply_board_specific_config( |
| 276 | board: "Board", |
| 277 | platformio_ini_path: Path, |
| 278 | example: str, |
| 279 | paths: "FastLEDPaths", |
| 280 | additional_defines: Optional[list[str]] = None, |
| 281 | additional_include_dirs: Optional[list[str]] = None, |
| 282 | additional_libs: Optional[list[str]] = None, |
| 283 | ) -> bool: |
| 284 | """Apply board-specific build configuration from Board class.""" |
| 285 | # Use provided paths object (which may have overrides) |
| 286 | paths.ensure_directories_exist() |
| 287 | |
| 288 | project_root = _get_project_root() |
| 289 | |
| 290 | # Generate platformio.ini content using the enhanced Board method |
| 291 | config_content = board.to_platformio_ini( |
| 292 | additional_defines=additional_defines, |
| 293 | additional_include_dirs=additional_include_dirs, |
| 294 | additional_libs=additional_libs, |
| 295 | include_platformio_section=True, |
| 296 | core_dir=str(paths.core_dir), |
| 297 | packages_dir=str(paths.packages_dir), |
| 298 | project_root=str(project_root), |
| 299 | build_cache_dir=str(paths.build_cache_dir), |
| 300 | ) |
| 301 | |
| 302 | # Apply PlatformIO cache optimization to speed up builds |
| 303 | try: |
| 304 | from ci.compiler.platformio_cache import PlatformIOCache |
| 305 | from ci.compiler.platformio_ini import PlatformIOIni |
| 306 | |
| 307 | # Parse the generated INI content |
| 308 | pio_ini = PlatformIOIni.parseString(config_content) |
| 309 | |
| 310 | # Set up global PlatformIO cache |
| 311 | cache = PlatformIOCache(paths.global_platformio_cache_dir) |
| 312 | |
| 313 | # Optimize by downloading and caching packages, replacing URLs with local file:// paths |
| 314 | pio_ini.optimize(cache) |
| 315 | |
| 316 | # Use the optimized content |
| 317 | config_content = str(pio_ini) |
| 318 | print( |
| 319 | f"Applied PlatformIO cache optimization using cache directory: {paths.global_platformio_cache_dir}" |
| 320 | ) |
| 321 | |
| 322 | except KeyboardInterrupt as ki: |
| 323 | handle_keyboard_interrupt(ki) |
| 324 | raise |
| 325 | except Exception as e: |
| 326 | # Graceful fallback to original URLs on cache failures |
| 327 | print( |
| 328 | f"Warning: PlatformIO cache optimization failed, using original URLs: {e}" |
| 329 | ) |
| 330 | # config_content remains unchanged (original URLs) |
| 331 | |
| 332 | platformio_ini_path.write_text(config_content) |
no test coverage detected