Centralized path management for FastLED board-specific directories and files.
| 17 | |
| 18 | |
| 19 | class FastLEDPaths: |
| 20 | """Centralized path management for FastLED board-specific directories and files.""" |
| 21 | |
| 22 | def __init__(self, board_name: str, project_root: Optional[Path] = None) -> None: |
| 23 | self.board_name = board_name |
| 24 | self.project_root = project_root or resolve_project_root() |
| 25 | self.home_dir = Path.home() |
| 26 | |
| 27 | # Base FastLED directory |
| 28 | self.fastled_root = self.home_dir / ".fastled" |
| 29 | # Initialize the optional cache directory override |
| 30 | self._global_platformio_cache_dir: Optional[Path] = None |
| 31 | |
| 32 | @property |
| 33 | def build_dir(self) -> Path: |
| 34 | """Project-local build directory for this board.""" |
| 35 | return self.project_root / ".build" / "pio" / self.board_name |
| 36 | |
| 37 | @property |
| 38 | def build_cache_dir(self) -> Path: |
| 39 | """Project-local build cache directory for this board.""" |
| 40 | return self.build_dir / "build_cache" |
| 41 | |
| 42 | @property |
| 43 | def platform_lock_file(self) -> Path: |
| 44 | """Platform-specific build lock file.""" |
| 45 | return self.build_dir.parent / f"{self.board_name}.lock" |
| 46 | |
| 47 | @property |
| 48 | def global_package_lock_file(self) -> Path: |
| 49 | """Global package installation lock file.""" |
| 50 | packages_lock_root = self.fastled_root / "pio" / "packages" |
| 51 | return packages_lock_root / f"{self.board_name}_global.lock" |
| 52 | |
| 53 | @property |
| 54 | def core_dir(self) -> Path: |
| 55 | """PlatformIO core directory (build cache, platforms).""" |
| 56 | return self.fastled_root / "compile" / "pio" / self.board_name |
| 57 | |
| 58 | @property |
| 59 | def packages_dir(self) -> Path: |
| 60 | """PlatformIO packages directory (toolchains, frameworks).""" |
| 61 | return self.home_dir / ".platformio" / "packages" |
| 62 | |
| 63 | @property |
| 64 | def global_platformio_cache_dir(self) -> Path: |
| 65 | """Global PlatformIO package cache directory (shared across all boards).""" |
| 66 | if self._global_platformio_cache_dir is not None: |
| 67 | return self._global_platformio_cache_dir |
| 68 | return self.fastled_root / "platformio_cache" |
| 69 | |
| 70 | def ensure_directories_exist(self) -> None: |
| 71 | """Create all necessary directories.""" |
| 72 | self.build_dir.mkdir(parents=True, exist_ok=True) |
| 73 | self.global_package_lock_file.parent.mkdir(parents=True, exist_ok=True) |
| 74 | self.core_dir.mkdir(parents=True, exist_ok=True) |
| 75 | self.packages_dir.mkdir(parents=True, exist_ok=True) |
| 76 | self.global_platformio_cache_dir.mkdir(parents=True, exist_ok=True) |
no outgoing calls
no test coverage detected