mirror of
https://github.com/pmret/papermario.git
synced 2025-12-19 17:58:12 -05:00
Add versioning (#187)
* fix vscode cpp extension messing with files.associations * move stuff * it builds! * symlink papermario.us.z64 * ci: put baserom in right place * add jp * fix splat dir * ignore starrod dump * .s deps * update jenkins * add dsl back * configure.py versions * wups * fine ethan * fix paths * configure: default to only the version(s) with existing baseroms * fix coverage * fix progress.py * progress.py verisoning * remove format.sh from CONTRIBUTING * update CONTRIBUTING * fix first_diff * diff.py: use ver/current/ * update splat.yaml * trying to fix subrepo * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "06a737f02d" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "06a737f02d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * configure fix * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "41786effd3" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "41786effd3" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" Co-authored-by: Ethan Roseman <ethteck@gmail.com>
This commit is contained in:
92
coverage.py
92
coverage.py
@@ -5,12 +5,6 @@ import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
DIR = os.path.dirname(__file__)
|
||||
NONMATCHINGS_DIR = Path(os.path.join(DIR, "asm", "nonmatchings"))
|
||||
|
||||
C_FILES = Path(os.path.join(DIR, "src")).rglob("*.c")
|
||||
ASM_FILES = NONMATCHINGS_DIR.rglob("*.s")
|
||||
|
||||
def strip_c_comments(text):
|
||||
def replacer(match):
|
||||
s = match.group(0)
|
||||
@@ -38,47 +32,59 @@ asm_func_pattern = re.compile(
|
||||
def include_asms_in_c(text):
|
||||
return (match.group(1) for match in asm_func_pattern.finditer(text))
|
||||
|
||||
matched = []
|
||||
asm = []
|
||||
for filename in C_FILES:
|
||||
with open(filename, "r") as file:
|
||||
text = strip_c_comments(file.read())
|
||||
matched.extend((m for m in funcs_in_c(text) if not m in matched))
|
||||
asm.extend((m for m in include_asms_in_c(text) if not m in asm))
|
||||
def stuff(version):
|
||||
DIR = os.path.dirname(__file__)
|
||||
NONMATCHINGS_DIR = Path(os.path.join(DIR, "ver", version, "asm", "nonmatchings"))
|
||||
|
||||
non_matched = [os.path.splitext(os.path.basename(filename))[0] for filename in ASM_FILES]
|
||||
C_FILES = Path(os.path.join(DIR, "src")).rglob("*.c")
|
||||
ASM_FILES = NONMATCHINGS_DIR.rglob("*.s")
|
||||
|
||||
partial_matched = [f for f in matched if f in asm]
|
||||
matched = [f for f in matched if not f in partial_matched]
|
||||
matched_but_undeleted_asm = set([f for f in matched if f in non_matched and not f in partial_matched])
|
||||
orphan_asm = set(non_matched) - set(asm) - matched_but_undeleted_asm
|
||||
missing_asm = set(asm) - set(non_matched)
|
||||
matched = []
|
||||
asm = []
|
||||
for filename in C_FILES:
|
||||
with open(filename, "r") as file:
|
||||
text = strip_c_comments(file.read())
|
||||
matched.extend((m for m in funcs_in_c(text) if not m in matched))
|
||||
asm.extend((m for m in include_asms_in_c(text) if not m in asm))
|
||||
|
||||
to_delete = matched_but_undeleted_asm | orphan_asm
|
||||
non_matched = [os.path.splitext(os.path.basename(filename))[0] for filename in ASM_FILES]
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "--help" in sys.argv:
|
||||
print("--fail-undeleted exit with error code 1 if obsolete .s functions exist")
|
||||
print("--delete delete obsolete .s functions without asking")
|
||||
exit()
|
||||
partial_matched = [f for f in matched if f in asm]
|
||||
matched = [f for f in matched if not f in partial_matched]
|
||||
matched_but_undeleted_asm = set([f for f in matched if f in non_matched and not f in partial_matched])
|
||||
orphan_asm = set(non_matched) - set(asm) - matched_but_undeleted_asm
|
||||
missing_asm = set(asm) - set(non_matched)
|
||||
|
||||
if len(matched_but_undeleted_asm) > 0:
|
||||
print(f"The following functions have been matched but their .s files remain: {matched_but_undeleted_asm}")
|
||||
if len(set(asm)) != len(set(non_matched)):
|
||||
if len(set(non_matched)) > len(set(asm)) and len(orphan_asm) > 0:
|
||||
print(f"The following functions are unmatched but are also unINCLUDEd: {orphan_asm}")
|
||||
elif len(missing_asm) > 0:
|
||||
print(f"warning: The following .s files are INCLUDEd but don't exist: {missing_asm}")
|
||||
to_delete = matched_but_undeleted_asm | orphan_asm
|
||||
|
||||
if len(to_delete) > 0:
|
||||
if "--fail-undeleted" in sys.argv:
|
||||
exit(1)
|
||||
elif "--delete" in sys.argv or input("Delete them [y/N]? ").upper() == "Y":
|
||||
for func in to_delete:
|
||||
f = next(NONMATCHINGS_DIR.rglob(func + ".s"))
|
||||
os.remove(f)
|
||||
if __name__ == "__main__":
|
||||
if "--help" in sys.argv:
|
||||
print("--fail-undeleted exit with error code 1 if obsolete .s functions exist")
|
||||
print("--delete delete obsolete .s functions without asking")
|
||||
exit()
|
||||
|
||||
# Remove empty directories
|
||||
for folder in list(os.walk(NONMATCHINGS_DIR)):
|
||||
if not os.listdir(folder[0]):
|
||||
os.removedirs(folder[0])
|
||||
if len(matched_but_undeleted_asm) > 0:
|
||||
print(f"The following functions have been matched but their .s files remain: {matched_but_undeleted_asm}")
|
||||
"""
|
||||
if len(set(asm)) != len(set(non_matched)):
|
||||
if len(set(non_matched)) > len(set(asm)) and len(orphan_asm) > 0:
|
||||
print(f"The following functions are unmatched but are also unINCLUDEd: {orphan_asm}")
|
||||
elif len(missing_asm) > 0:
|
||||
print(f"warning: The following .s files are INCLUDEd but don't exist: {missing_asm}")
|
||||
"""
|
||||
|
||||
if len(to_delete) > 0:
|
||||
if "--fail-undeleted" in sys.argv:
|
||||
exit(1)
|
||||
elif "--delete" in sys.argv or input("Delete them [y/N]? ").upper() == "Y":
|
||||
for func in to_delete:
|
||||
f = next(NONMATCHINGS_DIR.rglob(func + ".s"))
|
||||
os.remove(f)
|
||||
|
||||
# Remove empty directories
|
||||
for folder in list(os.walk(NONMATCHINGS_DIR)):
|
||||
if not os.listdir(folder[0]):
|
||||
os.removedirs(folder[0])
|
||||
|
||||
stuff("us")
|
||||
stuff("jp")
|
||||
|
||||
Reference in New Issue
Block a user