From f49a9cbb62f705cbc994d86b08cc1a9ae44622b5 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 17 Sep 2024 19:21:17 -0600 Subject: [PATCH] Fancy progress output fixes --- configure.py | 2 +- tools/project.py | 46 +++++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index 4ef4907..5ecb9ac 100755 --- a/configure.py +++ b/configure.py @@ -130,7 +130,7 @@ if not config.non_matching: config.binutils_tag = "2.42-1" config.compilers_tag = "20240706" config.dtk_tag = "v0.9.5" -config.objdiff_tag = "v2.0.0-beta.5" +config.objdiff_tag = "v2.0.0" config.sjiswrap_tag = "v1.1.1" config.wibo_tag = "0.6.11" diff --git a/tools/project.py b/tools/project.py index 2e7ad6b..c45f93e 100644 --- a/tools/project.py +++ b/tools/project.py @@ -234,14 +234,14 @@ def load_build_config( build_config: Dict[str, Any] = json.load(f) config_version = build_config.get("version") if config_version is None: - # Invalid config.json + print("Invalid config.json, regenerating...") f.close() os.remove(build_config_path) return None dtk_version = str(config.dtk_tag)[1:] # Strip v if versiontuple(config_version) < versiontuple(dtk_version): - # Outdated config.json + print("Outdated config.json, regenerating...") f.close() os.remove(build_config_path) return None @@ -1188,7 +1188,6 @@ def generate_objdiff_config( } # decomp.me compiler name mapping - # Commented out versions have not been added to decomp.me yet COMPILER_MAP = { "GC/1.0": "mwcc_233_144", "GC/1.1": "mwcc_233_159", @@ -1365,16 +1364,11 @@ def calculate_progress(config: ProjectConfig) -> None: def __init__(self, name: str) -> None: self.name: str = name self.code_total: int = 0 - self.code_fancy_frac: int = config.progress_code_fancy_frac - self.code_fancy_item: str = config.progress_code_fancy_item self.code_progress: int = 0 self.data_total: int = 0 - self.data_fancy_frac: int = config.progress_data_fancy_frac - self.data_fancy_item: str = config.progress_data_fancy_item self.data_progress: int = 0 - self.objects_progress: int = 0 - self.objects_total: int = 0 self.objects: Set[Object] = set() + self.objects_progress: int = 0 def add(self, build_obj: Dict[str, Any]) -> None: self.code_total += build_obj["code_size"] @@ -1384,7 +1378,6 @@ def calculate_progress(config: ProjectConfig) -> None: include_object = build_obj["name"] not in self.objects if include_object: self.objects.add(build_obj["name"]) - self.objects_total += 1 if build_obj["autogenerated"]: # Skip autogenerated objects @@ -1460,32 +1453,39 @@ def calculate_progress(config: ProjectConfig) -> None: print("Progress:") for unit in progress_units.values(): - if unit.objects_total == 0: + if len(unit.objects) == 0: continue code_frac = unit.code_frac() data_frac = unit.data_frac() print( - f" {unit.name}: {code_frac:.2%} code, {data_frac:.2%} data ({unit.objects_progress} / {unit.objects_total} files)" + f" {unit.name}: {code_frac:.2%} code, {data_frac:.2%} data ({unit.objects_progress} / {len(unit.objects)} files)" ) print(f" Code: {unit.code_progress} / {unit.code_total} bytes") print(f" Data: {unit.data_progress} / {unit.data_total} bytes") - if config.progress_use_fancy: - print( - "\nYou have {} out of {} {} and {} out of {} {}.".format( - math.floor(code_frac * unit.code_fancy_frac), - unit.code_fancy_frac, - unit.code_fancy_item, - math.floor(data_frac * unit.data_fancy_frac), - unit.data_fancy_frac, - unit.data_fancy_item, - ) + + if config.progress_use_fancy: + unit = progress_units.get("all") or progress_units.get("dol") + if unit is None or len(unit.objects) == 0: + return + + code_frac = unit.code_frac() + data_frac = unit.data_frac() + print( + "\nYou have {} out of {} {} and {} out of {} {}.".format( + math.floor(code_frac * config.progress_code_fancy_frac), + config.progress_code_fancy_frac, + config.progress_code_fancy_item, + math.floor(data_frac * config.progress_data_fancy_frac), + config.progress_data_fancy_frac, + config.progress_data_fancy_item, ) + ) # Generate and write progress.json progress_json: Dict[str, Any] = {} for id, unit in progress_units.items(): - if unit.objects_total == 0: + if len(unit.objects) == 0: continue progress_json[id] = { "code": unit.code_progress,