mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-27 00:10:31 +00:00
scripts: make update_decomp_ref.py
respect the game we are operating on (#1880)
This commit is contained in:
parent
4620f96574
commit
8117ed3bc7
@ -115,7 +115,7 @@ tasks:
|
||||
- cmd: python ./scripts/tasks/default-file-or-folder.py --path failures
|
||||
- cmd: '{{.OFFLINETEST_BIN_RELEASE_DIR}}/offline-test --iso_data_path "./iso_data/{{.GAME}}" --game {{.GAME}} --dump_current_output'
|
||||
ignore_error: true
|
||||
- python ./scripts/update_decomp_reference.py ./failures ./test/decompiler/reference/
|
||||
- python ./scripts/update_decomp_reference.py ./failures ./test/decompiler/reference/ --game {{.GAME}}
|
||||
- task: offline-tests
|
||||
# check-gsrc-file:
|
||||
# cmds:
|
||||
|
@ -35,3 +35,18 @@ def get_alltypes_path_from_game(game_name):
|
||||
return "./decompiler/config/all-types.gc"
|
||||
else:
|
||||
return "./decompiler/config/jak2/all-types.gc"
|
||||
|
||||
def get_ref_path_from_filename(game_name, file_name, ref_folder):
|
||||
file_list = get_file_list(game_name)
|
||||
src_path = ""
|
||||
for f in file_list:
|
||||
if f[2] != 3:
|
||||
continue
|
||||
if f[0] == file_name:
|
||||
src_path = f[4]
|
||||
break
|
||||
if src_path == "":
|
||||
print("couldn't determine ref path for {}:{}!".format(game_name, file_name))
|
||||
exit(1)
|
||||
path = "{}/{}/{}/{}_REF.gc".format(ref_folder, game_name, src_path, file_name)
|
||||
return path
|
||||
|
@ -3,34 +3,36 @@ import glob
|
||||
import argparse
|
||||
import shutil
|
||||
|
||||
from gsrc.utils import get_ref_path_from_filename
|
||||
|
||||
## Script to update failing _REF.gc files
|
||||
## Instructions:
|
||||
## run offline-test with the `--dump-mode` flag set. This generates a "failures" folder.
|
||||
## run offline-test with the `--dump_current_output` flag set. This generates a "failures" folder.
|
||||
## update reference like this
|
||||
## python3 ../scripts/update_decomp_reference.py ./failures ../test/decompiler/reference
|
||||
## python3 ../scripts/update_decomp_reference.py ./failures ../test/decompiler/reference --game [jak1|jak2]
|
||||
|
||||
## TODO - this has a bug and isn't properly game specific
|
||||
|
||||
def get_goal_files(root_dir):
|
||||
return [f for file in os.walk(root_dir) for f in glob.glob(os.path.join(file[0], '*.gc'))]
|
||||
def get_failures(root_dir):
|
||||
return [
|
||||
f
|
||||
for file in os.walk(root_dir)
|
||||
for f in glob.glob(os.path.join(file[0], "*.gc"))
|
||||
]
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(dest='diff', help='the failures folder')
|
||||
parser.add_argument(dest='reference', help='the test/decompiler/reference folder')
|
||||
parser.add_argument(dest="diff", help="the failures folder")
|
||||
parser.add_argument(dest="reference", help="the test/decompiler/reference folder")
|
||||
parser.add_argument("--game", help="The name of the game (jak1/jak2)", type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
location_map = {os.path.basename(x) : x for x in get_goal_files(args.reference)}
|
||||
|
||||
for replacement in get_goal_files(args.diff):
|
||||
base = os.path.basename(replacement)
|
||||
if base not in location_map:
|
||||
print("Could not find file {}".format(base))
|
||||
exit(-1)
|
||||
print("replace {} with {}".format(location_map[base], replacement))
|
||||
shutil.copyfile(replacement, location_map[base])
|
||||
for replacement in get_failures(args.diff):
|
||||
obj_name = os.path.basename(replacement).removesuffix(".gc").replace("_REF", "")
|
||||
|
||||
# Find gsrc path, given game-name
|
||||
ref_path = get_ref_path_from_filename(args.game, obj_name, args.reference)
|
||||
|
||||
print("replace {} with {}".format(ref_path, replacement))
|
||||
shutil.copyfile(replacement, ref_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
4
test/decompiler/reference/jak2/engine/ambient/ambient-h_REF.gc
generated
vendored
4
test/decompiler/reference/jak2/engine/ambient/ambient-h_REF.gc
generated
vendored
@ -1032,7 +1032,3 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
4
test/decompiler/reference/jak2/engine/gfx/foreground/foreground-h_REF.gc
generated
vendored
4
test/decompiler/reference/jak2/engine/gfx/foreground/foreground-h_REF.gc
generated
vendored
@ -360,7 +360,3 @@
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
|
3
test/decompiler/reference/jak2/engine/util/capture_REF.gc
generated
vendored
3
test/decompiler/reference/jak2/engine/util/capture_REF.gc
generated
vendored
@ -56,6 +56,3 @@
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user