scripts: make update_decomp_ref.py respect the game we are operating on (#1880)

This commit is contained in:
Tyler Wilding 2022-09-13 20:03:00 -04:00 committed by GitHub
parent 4620f96574
commit 8117ed3bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 29 deletions

View File

@ -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:

View File

@ -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

View File

@ -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()

View File

@ -1032,7 +1032,3 @@
)
)
)

View File

@ -360,7 +360,3 @@
;; failed to figure out what this is:
0

View File

@ -56,6 +56,3 @@
)
)