scripts: revive the gsrc linter script, missing too many mistakes

This commit is contained in:
Tyler Wilding
2022-10-09 21:41:55 -04:00
parent 27bd7371f3
commit ffafbee94a
3 changed files with 66 additions and 70 deletions
+4 -3
View File
@@ -89,6 +89,9 @@ tasks:
decomp-clean:
cmds:
- python ./scripts/tasks/clean-decomp.py --game "{{.GAME}}"
lint-gsrc-file:
cmds:
- python ./scripts/gsrc/lint-gsrc-file.py --game {{.GAME}} --file {{.FILE}}
update-gsrc:
cmds:
- python ./scripts/gsrc/update-gsrc-via-refs.py --game "{{.GAME}}" --decompiler "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler" --decompiler_config {{.DECOMP_CONFIG}}
@@ -96,6 +99,7 @@ tasks:
cmds:
- task: decomp-file
- python ./scripts/gsrc/update-from-decomp.py --game "{{.GAME}}" --file {{.FILE}}
- task: lint-gsrc-file
# TOOLS
analyze-ee-memory:
cmds:
@@ -131,9 +135,6 @@ tasks:
ignore_error: true
- python ./scripts/update_decomp_reference.py ./failures ./test/decompiler/reference/ --game {{.GAME}}
- task: offline-test-file
# check-gsrc-file:
# cmds:
# - python ./scripts/check-gsrc-file.py --files "{{.FILES}}"
type-test:
cmds:
- cmd: '{{.GOALCTEST_BIN_RELEASE_DIR}}/goalc-test --gtest_brief=0 --gtest_filter="*Jak2TypeConsistency*"'
-67
View File
@@ -1,67 +0,0 @@
import re
from jak1_file_list import file_list
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("--files")
args = parser.parse_args()
files = args.files.split(",")
throw_error = False
method_split_pattern = re.compile('t9-\d+\s\(method-of-object')
function_split_pattern = re.compile('\(t9-\d+\)')
missing_res_tag_pattern = re.compile('(sv-\d{2,} int)')
decompiler_error_pattern = re.compile(';; ERROR')
missing_arg = re.compile('local-vars.*none\)')
for file in files:
src_path = ""
for f in file_list:
if f[2] != 3:
continue
if f[0] == file:
src_path = f[4]
break
if not os.path.exists("./goal_src/{}".format(src_path)):
print("{} couldn't find in /goal_src!".format(file))
throw_error = True
continue
file_path = "./goal_src/{}/{}.gc".format(src_path, file)
with open(file_path) as f:
for lineno, line in enumerate(f):
method_split_match = method_split_pattern.search(line)
if method_split_match:
print("method_split - {}:{}".format(file_path, lineno + 1))
throw_error = True
continue
function_split_match = function_split_pattern.search(line)
if function_split_match:
print("function_split - {}:{}".format(file_path, lineno + 1))
throw_error = True
continue
missing_res_tag_match = missing_res_tag_pattern.search(line)
if missing_res_tag_match:
print("missing_res_tag - {}:{}".format(file_path, lineno + 1))
throw_error = True
continue
decompiler_error_match = decompiler_error_pattern.search(line)
if decompiler_error_match:
print("decompiler_error - {}:{}".format(file_path, lineno + 1))
throw_error = True
continue
missing_arg_match = missing_arg.search(line)
if missing_arg_match:
print("missing_arg - {}:{}".format(file_path, lineno + 1))
throw_error = True
continue
if throw_error:
print("found potential problems!")
exit(1)
else:
print("looks good!")
+62
View File
@@ -0,0 +1,62 @@
import re
import argparse
import os
from utils import get_gsrc_path_from_filename
parser = argparse.ArgumentParser("lint-gsrc-file")
parser.add_argument("--game", help="The name of the game", type=str)
parser.add_argument("--file", help="The name of the file", type=str)
args = parser.parse_args()
throw_error = False
# TODO - if more code is added here overtime, be smarter about this / group errors
method_split_pattern = re.compile('method-of-type')
function_split_pattern = re.compile('\(t9-\d+(?:\s+[^\s]+\s*)?\)')
missing_res_tag_pattern = re.compile('.pcpyud')
decompiler_error_pattern = re.compile(';; ERROR')
missing_arg = re.compile('local-vars.*[at].*\s+none\)')
casting_stack_var = re.compile('the-as\s+[^\s]*\s+.*\(new \'stack')
src_path = get_gsrc_path_from_filename(args.game, args.file)
print("Linting GOAL_SRC File...")
with open(src_path) as f:
for lineno, line in enumerate(f):
method_split_match = method_split_pattern.search(line)
if method_split_match:
print("method_split - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
function_split_match = function_split_pattern.search(line)
if function_split_match:
print("function_split - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
missing_res_tag_match = missing_res_tag_pattern.search(line)
if missing_res_tag_match:
print("missing_res_tag - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
decompiler_error_match = decompiler_error_pattern.search(line)
if decompiler_error_match:
print("decompiler_error - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
missing_arg_match = missing_arg.search(line)
if missing_arg_match:
print("missing_arg - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
casting_stack_var_match = casting_stack_var.search(line)
if casting_stack_var_match:
print("casting stack var - {}:{}".format(src_path, lineno + 1))
throw_error = True
continue
if throw_error:
print("Found potential problems, exiting with code 1!")
exit(1)
else:
print("Looks good!")