Fix diff.py, add support for objdiff

This commit is contained in:
Cuyler36
2024-01-02 17:11:38 -05:00
parent 5125ebd972
commit 77ce517b85
4 changed files with 29 additions and 2 deletions
+1
View File
@@ -18,3 +18,4 @@ tools/cli.ini
tools/cli.py
src/data/bin1
src/data/bin2
objdiff.json
+26
View File
@@ -723,6 +723,30 @@ def make_asm_list(path: str, asm_includes: List[AsmInclude]):
forcefiles = []
def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text
def make_objdiff_json(sources: List[Source]):
data = {
'min_version' : "0.4.3",
'custom_make' : "ninja",
'target_dir' : f"{c.EXPECTED}/build",
'base_dir' : f"{c.BUILDDIR}",
'build_target' : False,
'objects' : [
{
'path' : remove_prefix(src.o_path, "$builddir/"),
'name' : src.src_path,
}
for src in sources
if src.decompiled
]
}
with open("objdiff.json", 'w') as f:
json.dump(data, f, indent=4)
dol_sources = load_sources(c.DOL_CTX)
dol_gen_includes = find_gen_includes(dol_sources)
make_asm_list(c.DOL_ASM_LIST, dol_gen_includes[AsmInclude])
@@ -731,6 +755,8 @@ rel_sources = load_sources(c.REL_CTX)
rel_gen_includes = find_gen_includes(rel_sources)
make_asm_list(c.REL_ASM_LIST, rel_gen_includes[AsmInclude])
make_objdiff_json(dol_sources + rel_sources)
##########
# Builds #
##########
+1 -1
View File
@@ -1118,7 +1118,7 @@ def search_map_file(
find = re.findall(
re.compile(
# ram elf rom alignment
r" \S+ \S+ (\S+) (\S+) +\S+ "
r" \S+ (\S+) (\S+) +\S+ "
+ re.escape(fn_name)
+ r"(?: \(entry of "
+ re.escape(config.diff_section)
+1 -1
View File
@@ -21,4 +21,4 @@ def apply(config, args: Namespace):
config["show_line_numbers_default"] = True
def add_custom_arguments(parser: ArgumentParser):
parser.add_argument("-r", "--rel", action="store_true", help="(SPM) Diff a function in relF.rel")
parser.add_argument("-r", "--rel", action="store_true", help="(AC) Diff a function in foresta.rel")