From 3a2e0823a8473dae4104f4e48aefec179657663a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 25 Oct 2024 01:42:19 +0200 Subject: [PATCH] Don't make built target available if it is missing original path, recompiled path, or recompiled pdb path --- reccmp/project/detect.py | 24 ++++++++++++++++-------- reccmp/tools/project.py | 3 +-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/reccmp/project/detect.py b/reccmp/project/detect.py index b9966450..55a72aac 100644 --- a/reccmp/project/detect.py +++ b/reccmp/project/detect.py @@ -179,24 +179,33 @@ def from_directory(cls, directory: Path) -> "RecCmpBuiltProject": original_path_str = user_target_data.get("path") if not original_path_str: - raise InvalidRecCmpProjectException( - f"{user_config}: targets.{target_id}.path is missing" + logger.warning( + "%s: targets.%s.path is missing. Target will not be available.", + user_config, + target_id, ) + continue original_path = Path(original_path_str.strip()) build_target_data = build_data.get("targets", {}).get(target_id, {}) recompiled_path_str = build_target_data.get("path") if not recompiled_path_str: - raise InvalidRecCmpProjectException( - f"{build_config}: targets.{target_id}.path is missing." + logger.warning( + "%s: targets.%s.path is missing. Target will not be available.", + build_config, + target_id, ) + continue recompiled_path = Path(recompiled_path_str) recompiled_pdb_str = build_target_data.get("pdb") if not recompiled_path_str: - raise InvalidRecCmpProjectException( - f"{build_config}: targets.{target_id}.pdb is missing." + logger.warning( + "%s: targets.%s.pdb is missing. Target will not be available.", + build_config, + target_id, ) + continue recompiled_pdb = Path(recompiled_pdb_str) project.targets[target_id] = RecCmpBuiltTarget( @@ -355,7 +364,7 @@ def detect_project( search_path: list[Path], detect_what: DetectWhat, build_directory: typing.Optional[Path] = None, -) -> RecCmpProject: +) -> None: yaml = ruamel.yaml.YAML() project_config_path = project_directory / RECCMP_PROJECT_CONFIG @@ -432,4 +441,3 @@ def detect_project( with build_config_path.open("w") as f: yaml.dump(data=build_data, stream=f) - return 0 diff --git a/reccmp/tools/project.py b/reccmp/tools/project.py index ac566d07..4b511b06 100755 --- a/reccmp/tools/project.py +++ b/reccmp/tools/project.py @@ -113,8 +113,7 @@ def main(): f"Cannot find reccmp project. Run '{parser.prog} create' first." ) try: - # pylint: disable=unused-argument - project = detect_project( + detect_project( project_directory=project.project_config_path.parent, search_path=args.detect_search_path, detect_what=args.detect_what,