From 9f920f20400fe0d624a76e4428ec0930d55116a5 Mon Sep 17 00:00:00 2001 From: coco875 <59367621+coco875@users.noreply.github.com> Date: Fri, 16 Aug 2024 23:45:32 +0200 Subject: [PATCH] Action more info when it doesn't match and fix first diff (#662) * Update linux-compile.yml * fix first-diff * Update first-diff.py --------- Co-authored-by: MegaMech --- .github/workflows/linux-compile.yml | 2 +- first-diff.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux-compile.yml b/.github/workflows/linux-compile.yml index 7ef63168d1..314420b52a 100644 --- a/.github/workflows/linux-compile.yml +++ b/.github/workflows/linux-compile.yml @@ -27,4 +27,4 @@ jobs: cp -r complementary_file/* . echo "${{ secrets.AES_KEY }}" | openssl enc -d -aes-256-cbc -pass stdin -pbkdf2 -in baserom.us.z64.aes -out baserom.us.z64 make assets - make -j \ No newline at end of file + make -j || ./first-diff.py \ No newline at end of file diff --git a/first-diff.py b/first-diff.py index a208f40351..7b6d088cf8 100755 --- a/first-diff.py +++ b/first-diff.py @@ -2,6 +2,7 @@ import os.path import argparse from subprocess import check_call +import re # TODO: -S argument for shifted ROMs @@ -118,8 +119,9 @@ def search_map(rom_addr): if "noload" in line or "noload" in prev_line: ram_offset = None continue - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) + hex_number = re.findall(r"0x[0-9a-fA-F]+", line) + ram = int(hex_number[0], 0) # int(line[16 : 16 + 18], 0) + rom = int(hex_number[2], 0)# int(line[59 : 59 + 18], 0) ram_offset = ram - rom continue prev_line = line @@ -131,10 +133,11 @@ def search_map(rom_addr): or " 0x" not in line ): continue - ram = int(line[16 : 16 + 18], 0) + hex_number = re.findall(r"0x[0-9a-fA-F]+", line) + ram = int(hex_number[0], 0) # int(line[16 : 16 + 18], 0) rom = ram - ram_offset fn = line.split()[-1] - if "0x" in fn: + if fn.startswith("0x"): ram_offset = None continue if rom > rom_addr or (rom_addr & 0x80000000 and ram > rom_addr): @@ -265,7 +268,7 @@ def hexbytes(bs): map_search_diff.append(search_map(i)) if diffs == 0: print("No differences!") - exit() + exit(0) definite_shift = diffs > shift_cap if not definite_shift: if (diffs > 1): @@ -288,7 +291,7 @@ def hexbytes(bs): + basemap + " and rerun this script." ) - exit() + exit(1) if not map_diff(): print(f"No ROM shift{' (!?)' if definite_shift else ''}")