From 5b3810dba91821a87b202f7c573a9e5d504c85db Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 29 Dec 2023 17:19:42 -0500 Subject: [PATCH] Update decomctx.py include paths --- tools/decompctx.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/decompctx.py b/tools/decompctx.py index 3b27d6c42..c6ff9c723 100755 --- a/tools/decompctx.py +++ b/tools/decompctx.py @@ -17,7 +17,15 @@ import re script_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.abspath(os.path.join(script_dir, "..")) src_dir = os.path.join(root_dir, "src") -include_dir = os.path.join(root_dir, "include") +include_dirs = [ + os.path.join(root_dir, "include"), + os.path.join(root_dir, "src"), + os.path.join(root_dir, "src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include"), + os.path.join(root_dir, "src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include"), + os.path.join(root_dir, "src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Include"), + os.path.join(root_dir, "src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include"), + os.path.join(root_dir, "src/PowerPC_EABI_Support/Runtime/Inc"), +] include_pattern = re.compile(r'^#include\s*[<"](.+?)[>"]$') guard_pattern = re.compile(r'^#ifndef\s+(.*)$') @@ -26,21 +34,23 @@ defines = set() def import_h_file(in_file: str, r_path: str) -> str: rel_path = os.path.join(root_dir, r_path, in_file) - inc_path = os.path.join(include_dir, in_file) if os.path.exists(rel_path): return import_c_file(rel_path) - elif os.path.exists(inc_path): - return import_c_file(inc_path) else: - print("Failed to locate", in_file) - exit(1) + for inc_dir in include_dirs: + inc_path = os.path.join(inc_dir, in_file) + if os.path.exists(inc_path): + return import_c_file(inc_path) + else: + print("Failed to locate", in_file) + exit(1) def import_c_file(in_file) -> str: in_file = os.path.relpath(in_file, root_dir) out_text = '' try: - with open(in_file, encoding="utf-8") as file: + with open(in_file, encoding="shift-jis") as file: out_text += process_file(in_file, list(file)) except Exception: with open(in_file) as file: