Files
jak-project/scripts/gsrc/update-files-from-decomp-plan.py
T
Tyler Wilding 9c86c86c74 d/jx: More files (#4360)
Breaks the 300 file milestone, also includes the majority of mips2c
functions carried forward. Some functions need some fixes in the c++
code to mips2c properly, and a small handful of the mips2c functions
require manual patching -- all spots were marked with `TODO - fix` that
had to be commented out to get things compiling.
2026-09-04 09:27:06 -04:00

60 lines
1.4 KiB
Python

import json
import os
import subprocess
import shutil
# assume this is available/importable
from utils import get_ref_path_from_filename
BASE_DIR = "./"
OUT_DIR = os.path.join(BASE_DIR, "decompiler_out", "jakx")
REF_BASE = os.path.join(BASE_DIR, "test", "decompiler", "reference")
def run_decomp(name: str):
env = os.environ.copy()
env["FILE"] = name
env["GAME"] = "jakx"
subprocess.run(
["task", "decomp-file"],
env=env,
cwd=BASE_DIR,
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
def copy_to_ref(name: str):
src = os.path.join(OUT_DIR, f"{name}_disasm.gc")
if not os.path.exists(src):
return # or raise
ref_path = get_ref_path_from_filename("jakx", name, REF_BASE)
# ensure directory exists
os.makedirs(os.path.dirname(ref_path), exist_ok=True)
# enforce renamed filename
dst = os.path.join(os.path.dirname(ref_path), f"{name}_REF.gc")
shutil.copyfile(src, dst)
with open("./scripts/gsrc/_decomp-plan.json", "r") as f:
data = json.load(f)
for i, entry in enumerate(data):
name = entry.get("name")
print(f"[{i}/{len(data)}] {name}")
done = entry.get("done")
if entry.get("skip"):
print(f"skipping {name}")
continue
if done and name:
run_decomp(name)
copy_to_ref(name)
# exit(1)