| 27 | |
| 28 | |
| 29 | def load_tools(build_info_path: Path) -> Tools: |
| 30 | build_info: dict[str, Any] = json.loads(build_info_path.read_text()) |
| 31 | board_info: dict[str, Any] = build_info[next(iter(build_info))] |
| 32 | aliases: dict[str, str] = board_info["aliases"] |
| 33 | as_path = Path(aliases["as"]) |
| 34 | ld_path = Path(aliases["ld"]) |
| 35 | objcopy_path = Path(aliases["objcopy"]) |
| 36 | objdump_path = Path(aliases["objdump"]) |
| 37 | cpp_filt_path = Path(aliases["c++filt"]) |
| 38 | nm_path = Path(aliases["nm"]) |
| 39 | if sys.platform == "win32": |
| 40 | as_path = as_path.with_suffix(".exe") |
| 41 | ld_path = ld_path.with_suffix(".exe") |
| 42 | objcopy_path = objcopy_path.with_suffix(".exe") |
| 43 | objdump_path = objdump_path.with_suffix(".exe") |
| 44 | cpp_filt_path = cpp_filt_path.with_suffix(".exe") |
| 45 | nm_path = nm_path.with_suffix(".exe") |
| 46 | out = Tools(as_path, ld_path, objcopy_path, objdump_path, cpp_filt_path, nm_path) |
| 47 | tools = [as_path, ld_path, objcopy_path, objdump_path, cpp_filt_path, nm_path] |
| 48 | for tool in tools: |
| 49 | if not tool.exists(): |
| 50 | raise FileNotFoundError(f"Tool not found: {tool}") |
| 51 | return out |
| 52 | |
| 53 | |
| 54 | def _list_builds() -> list[Path]: |