Analyzer for build_info.json files generated by PlatformIO builds.
| 87 | |
| 88 | |
| 89 | class BuildInfoAnalyzer: |
| 90 | """Analyzer for build_info.json files generated by PlatformIO builds.""" |
| 91 | |
| 92 | def __init__(self, build_dir: str): |
| 93 | """ |
| 94 | Initialize the analyzer. |
| 95 | |
| 96 | Args: |
| 97 | build_dir: Directory containing platform build directories |
| 98 | """ |
| 99 | self.build_dir = Path(build_dir) |
| 100 | |
| 101 | def list_available_boards(self) -> list[str]: |
| 102 | """ |
| 103 | List all boards that have build_info.json files. |
| 104 | |
| 105 | Returns: |
| 106 | List of board names that have been built |
| 107 | """ |
| 108 | boards: list[str] = [] |
| 109 | if not self.build_dir.exists(): |
| 110 | return boards |
| 111 | |
| 112 | for item in self.build_dir.iterdir(): |
| 113 | if item.is_dir() and (item / "build_info.json").exists(): |
| 114 | boards.append(item.name) |
| 115 | |
| 116 | return sorted(boards) |
| 117 | |
| 118 | def get_build_info_path(self, board_name: str) -> Optional[Path]: |
| 119 | """ |
| 120 | Get the path to build_info.json for a specific board. |
| 121 | |
| 122 | Args: |
| 123 | board_name: Name of the board (e.g., 'uno', 'esp32dev') |
| 124 | |
| 125 | Returns: |
| 126 | Path to build_info.json file or None if not found |
| 127 | """ |
| 128 | build_info_path = self.build_dir / board_name / "build_info.json" |
| 129 | if build_info_path.exists(): |
| 130 | return build_info_path |
| 131 | return None |
| 132 | |
| 133 | def load_build_info(self, board_name: str) -> Optional[dict[str, Any]]: |
| 134 | """ |
| 135 | Load and parse build_info.json for a board. |
| 136 | |
| 137 | Args: |
| 138 | board_name: Name of the board |
| 139 | |
| 140 | Returns: |
| 141 | Parsed JSON data or None if file not found |
| 142 | """ |
| 143 | build_info_path = self.get_build_info_path(board_name) |
| 144 | if not build_info_path: |
| 145 | return None |
| 146 |
no outgoing calls
no test coverage detected