integrate debugedit tool into meson build process

This commit is contained in:
Joshua Smith
2024-10-04 11:58:13 -05:00
parent 851e3ab17b
commit 33ac4aa146
5 changed files with 38 additions and 10 deletions

View File

@@ -21,10 +21,7 @@ export MESON_RSP_THRESHOLD=16387
if [ "$target" = test ]; then
"${MESON:-meson}" test -C build "$@"
elif [ "$target" = rom ]; then
"${MESON:-meson}" compile -C build "pokeplatinum.us.nds"
"${MESON:-meson}" compile -C build "pokeplatinum.us.nds" "debug.nef"
else
"${MESON:-meson}" compile -C build "$target" "$@"
fi
# remap incorrect source paths due to Wine build process
python3 fixup_elf2.py

View File

@@ -228,6 +228,22 @@ pokeplatinum_nds = custom_target('pokeplatinum.us.nds',
build_by_default: true
)
############################################################
### NEF FIXER ###
############################################################
nef_fixer = custom_target('debug.nef',
output: [
'debug.nef'
],
input: [
main
],
command : [
nef_fixer_py, '@INPUT@', '@OUTPUT@'
],
build_by_default: true
)
############################################################
### TESTS ###

View File

@@ -59,9 +59,14 @@ void LoadOverlayGDB(const FSOverlayID overlayID)
GF_ASSERT(FS_LoadOverlayInfo(&overlayInfo, MI_PROCESSOR_ARM9, overlayID) == TRUE);
// 2. add entry to _ovly_table
// note that this is a little hacky. the VMA is correct but the LMA is not exposed by the OverlayManager
// and the size field is not correct compared to what's stored in the NEF.
// the standard overlay manager in GDB bases comparisons on VMA and LMA, so it's not viable here.
// requires a custom GDB build which uses section name and which can override section size.
// see
_ovly_table[overlayID].vma = overlayInfo.header.ram_address;
_ovly_table[overlayID].lma = 0;
_ovly_table[overlayID].size = overlayInfo.header.ram_size;
_ovly_table[overlayID].size = overlayInfo.header.ram_size;
_ovly_table[overlayID].mapped = 1;
_ovly_debug_event();
}

View File

@@ -10,3 +10,4 @@ make_species_tables_py = find_program('make_species_tables.py', native: true)
make_tutorable_moves_py = find_program('make_tutorable_moves.py', native: true)
make_pokedex_data_py = find_program('make_pokedex_data.py', native: true)
make_pokedex_message_banks_py = find_program('make_pokedex_message_banks.py', native: true)
nef_fixer_py = find_program('nef_fixer.py', native: true)

View File

@@ -1,15 +1,24 @@
#!/usr/bin/env python3
import subprocess
import os
import shutil
import sys
try:
os.remove("build/sources.txt")
os.remove("sources.txt")
except:
pass
print("Retrieving source file list via debugedit")
subprocess.run(["debugedit", "-l", "build/sources.txt", "build/main.nef"])
source = sys.argv[1]
dest = sys.argv[2]
with open("build/sources.txt") as f:
print(f"Copying {source} to {dest}")
shutil.copyfile(source, dest)
print("Retrieving source file list via debugedit")
subprocess.run(["debugedit", "-l", "sources.txt", dest])
with open("sources.txt") as f:
content = f.read()
all_sources = content.split('\0')
@@ -29,4 +38,4 @@ print(f"Identified {len(source_paths)} unique source directories from source fil
for source in source_paths:
remapped = source.replace("\\", "/")[2:]
print(f"Remapping source path from {source} to {remapped} using debugedit.")
subprocess.run(["debugedit", "-b", source, "-d", remapped, "build/main.nef"])
subprocess.run(["debugedit", "-b", source, "-d", remapped, dest])