diff --git a/tools/tp.py b/tools/tp.py index d23c9a3f6d9..485ef52eb8c 100644 --- a/tools/tp.py +++ b/tools/tp.py @@ -4,11 +4,11 @@ tp.py - Various tools used for the zeldaret/tp project progress: Calculates decompilation progress. By assuming that the code was generated by 'dol2asm' and that all non-code sections are fully decompiled. The script calculate the amount of bytes -that are left to decompile (all code in the .s files). +that are left to decompile (all code in the .s files). -pull-request: Helps people make sure that everything is OK before making pull-requests. -The script does three things: remove unused asm files, rebuild the full project, and -clang-format every file. +pull-request: Helps people make sure that everything is OK before making pull-requests. +The script does three things: remove unused asm files, rebuild the full project, and +clang-format every file. """ @@ -113,7 +113,7 @@ def check(debug, game_path, build_path): @dataclass class ProgressSection: name: str - addr: int + addr: int size: int decompiled: int @@ -239,17 +239,16 @@ def calculate_progress(matching, format, print_rels): table.add_row("total", f"{dol_progress.percentage:10.6f}%", f"{dol_progress.decompiled}", f"{dol_progress.size}") CONSOLE.print(table) - table = Table(title="RELs") - table.add_column("Section", justify="right", - style="cyan", no_wrap=True) - table.add_column("Percentage", style="green") - table.add_column("Decompiled (bytes)", - justify="right", style="bright_yellow") - table.add_column("Total (bytes)", justify="right", - style="bright_magenta") - - if print_rels: + table = Table(title="RELs") + table.add_column("Section", justify="right", + style="cyan", no_wrap=True) + table.add_column("Percentage", style="green") + table.add_column("Decompiled (bytes)", + justify="right", style="bright_yellow") + table.add_column("Total (bytes)", justify="right", + style="bright_magenta") + for rel in rels_progress: table.add_row(rel.name, f"{rel.percentage:10.6f}%", f"{rel.decompiled}", f"{rel.size}") @@ -267,7 +266,12 @@ def calculate_progress(matching, format, print_rels): style="bright_magenta") table.add_row("main.dol", f"{dol_progress.percentage:10.6f}%", f"{dol_progress.decompiled}", f"{dol_progress.size}") - table.add_row("RELs", f"{100 * (rel_decompiled / rel_size):10.6f}%", f"{rel_decompiled}", f"{rel_size}") + if rels_progress: + table.add_row("RELs", f"{100 * (rel_decompiled / rel_size):10.6f}%", f"{rel_decompiled}", f"{rel_size}") + else: + # if we don't have any rel progress, just indicate N/A + table.add_row("RELs", "–".center(11), f"–", f"–") + table.add_row("", "", "", "") table.add_row("total", f"{100 * (decompiled_size / total_size):10.6f}%", f"{decompiled_size}", f"{total_size}") @@ -644,7 +648,7 @@ class CheckException(Exception): ... def check_sha1(game_path, build_path): - + dol_path = game_path.joinpath("main.dol") if not dol_path.exists(): raise CheckException(f"File not found: '{dol_path}'") @@ -716,7 +720,7 @@ def check_sha1(game_path, build_path): yaz0_data = data if struct.unpack('>I', data[:4])[0] == 0x59617A30: data = yaz0.decompress(io.BytesIO(data)) - + rel = librel.read(data) CURRENT[rel.index] = (str(rel_filepath), sha1_from_data(yaz0_data),sha1_from_data(data),)