From 8a4fdc3f3a932f9cfc244dc80112881b1529ed3f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 6 Aug 2023 15:55:19 -0400 Subject: [PATCH] Update dtk & use config.yml --- .gitignore | 4 +-- config/G2ME01/config.yml | 3 ++ config/G2ME01/splits.txt | 8 +++-- config/G2ME01/symbols.txt | 62 +++++++++++++++++++-------------------- config/G2MJ01/config.yml | 3 ++ config/G2MP01/config.yml | 3 ++ configure.py | 45 ++++++++++++++-------------- orig/G2ME01/.gitkeep | 0 orig/G2MJ01/.gitkeep | 0 orig/G2MP01/.gitkeep | 0 tools/dtk_version | 2 +- 11 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 config/G2ME01/config.yml create mode 100644 config/G2MJ01/config.yml create mode 100644 config/G2MP01/config.yml create mode 100644 orig/G2ME01/.gitkeep create mode 100644 orig/G2MJ01/.gitkeep create mode 100644 orig/G2MP01/.gitkeep diff --git a/.gitignore b/.gitignore index 899cebe..a81023f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ __pycache__ build build.ninja -orig/* -!orig/*.sha1 +orig/*/* +!orig/*/.gitkeep tools/mwcc_compiler/* !tools/mwcc_compiler/.gitkeep .ninja_deps diff --git a/config/G2ME01/config.yml b/config/G2ME01/config.yml new file mode 100644 index 0000000..6870b86 --- /dev/null +++ b/config/G2ME01/config.yml @@ -0,0 +1,3 @@ +object: orig/G2ME01/sys/main.dol +splits: config/G2ME01/splits.txt +symbols: config/G2ME01/symbols.txt diff --git a/config/G2ME01/splits.txt b/config/G2ME01/splits.txt index 30d8207..2deecf7 100644 --- a/config/G2ME01/splits.txt +++ b/config/G2ME01/splits.txt @@ -1,3 +1,6 @@ +MetroidPrime/Player/CPlayerState.cpp: + .text start:0x80084864 end:0x80086410 + Runtime/__init_cpp_exceptions.cpp: .text start:0x80345C34 end:0x80345CA4 .ctors start:0x803A54A0 end:0x803A54A4 @@ -5,10 +8,9 @@ Runtime/__init_cpp_exceptions.cpp: .sdata start:0x80418CA8 end:0x80418CB0 Runtime/Gecko_ExceptionPPC.cp: + extab start:0x800036D8 end:0x8000374C + extabindex start:0x800037CC end:0x80003820 .text start:0x80345CA4 end:0x803470DC .rodata start:0x803B03B0 end:0x803B0448 .data start:0x803BBFD8 end:0x803BC0C0 .bss start:0x803E0640 end:0x803E0650 - -MetroidPrime/Player/CPlayerState.cpp: - .text start:0x80084864 end:0x80086410 diff --git a/config/G2ME01/symbols.txt b/config/G2ME01/symbols.txt index f91de93..49db389 100644 --- a/config/G2ME01/symbols.txt +++ b/config/G2ME01/symbols.txt @@ -15459,24 +15459,24 @@ fn_80344C1C = .text:0x80344C1C; // type:function size:0x54 align:0x4 fn_80344C70 = .text:0x80344C70; // type:function size:0xA0 align:0x4 __va_arg = .text:0x80344D10; // type:function size:0xC8 scope:global __destroy_global_chain = .text:0x80344DD8; // type:function size:0x48 scope:global -__register_global_object = .text:0x80344E20; // type:function size:0x18 align:0x4 -__copy = .text:0x80344E38; // type:function size:0x30 -__dt__Q23std9exceptionFv = .text:0x80344E68; // type:function size:0x74 +__register_global_object = .text:0x80344E20; // type:function size:0x18 scope:global align:0x4 +__copy = .text:0x80344E38; // type:function size:0x30 scope:global +__dt__Q23std9exceptionFv = .text:0x80344E68; // type:function size:0x74 scope:weak fn_80344EDC = .text:0x80344EDC; // type:function size:0x4C -what__Q23std9exceptionCFv = .text:0x80344F28; // type:function size:0xC align:0x4 -__destroy_arr = .text:0x80344F34; // type:function size:0x78 -__construct_array = .text:0x80344FAC; // type:function size:0xFC -__dt__26__partial_array_destructorFv = .text:0x803450A8; // type:function size:0xB8 -__throw_catch_compare = .text:0x80345160; // type:function size:0x22C -unexpected__3stdFv = .text:0x8034538C; // type:function size:0x28 -terminate__3stdFv = .text:0x803453B4; // type:function size:0x28 -duhandler__3stdFv = .text:0x803453DC; // type:function size:0x28 -dthandler__3stdFv = .text:0x80345404; // type:function size:0x20 -__ptmf_test = .text:0x80345424; // type:function size:0x30 align:0x4 -__ptmf_scall = .text:0x80345454; // type:function size:0x28 -__ptmf_scall4 = .text:0x8034547C; // type:function size:0x28 align:0x4 -__cvt_fp2unsigned = .text:0x803454A4; // type:function size:0x5C -__save_fpr = .text:0x80345500; // type:function size:0x4C align:0x4 +what__Q23std9exceptionCFv = .text:0x80344F28; // type:function size:0xC scope:weak align:0x4 +__destroy_arr = .text:0x80344F34; // type:function size:0x78 scope:global +__construct_array = .text:0x80344FAC; // type:function size:0xFC scope:global +__dt__26__partial_array_destructorFv = .text:0x803450A8; // type:function size:0xB8 scope:weak +__throw_catch_compare = .text:0x80345160; // type:function size:0x22C scope:global +unexpected__3stdFv = .text:0x8034538C; // type:function size:0x28 scope:global +terminate__3stdFv = .text:0x803453B4; // type:function size:0x28 scope:global +duhandler__3stdFv = .text:0x803453DC; // type:function size:0x28 scope:local +dthandler__3stdFv = .text:0x80345404; // type:function size:0x20 scope:local +__ptmf_test = .text:0x80345424; // type:function size:0x30 scope:global align:0x4 +__ptmf_scall = .text:0x80345454; // type:function size:0x28 scope:global +__ptmf_scall4 = .text:0x8034547C; // type:function size:0x28 scope:global align:0x4 +__cvt_fp2unsigned = .text:0x803454A4; // type:function size:0x5C scope:global +__save_fpr = .text:0x80345500; // type:function size:0x4C scope:global align:0x4 _savefpr_14 = .text:0x80345500; // type:label scope:global _savefpr_15 = .text:0x80345504; // type:label scope:global _savefpr_16 = .text:0x80345508; // type:label scope:global @@ -15495,7 +15495,7 @@ _savefpr_28 = .text:0x80345538; // type:label scope:global _savefpr_29 = .text:0x8034553C; // type:label scope:global _savefpr_30 = .text:0x80345540; // type:label scope:global _savefpr_31 = .text:0x80345544; // type:label scope:global -__restore_fpr = .text:0x8034554C; // type:function size:0x4C align:0x4 +__restore_fpr = .text:0x8034554C; // type:function size:0x4C scope:global align:0x4 _restfpr_14 = .text:0x8034554C; // type:label scope:global _restfpr_15 = .text:0x80345550; // type:label scope:global _restfpr_16 = .text:0x80345554; // type:label scope:global @@ -15514,7 +15514,7 @@ _restfpr_28 = .text:0x80345584; // type:label scope:global _restfpr_29 = .text:0x80345588; // type:label scope:global _restfpr_30 = .text:0x8034558C; // type:label scope:global _restfpr_31 = .text:0x80345590; // type:label scope:global -__save_gpr = .text:0x80345598; // type:function size:0x4C +__save_gpr = .text:0x80345598; // type:function size:0x4C scope:global _savegpr_14 = .text:0x80345598; // type:label scope:global _savegpr_15 = .text:0x8034559C; // type:label scope:global _savegpr_16 = .text:0x803455A0; // type:label scope:global @@ -15533,7 +15533,7 @@ _savegpr_28 = .text:0x803455D0; // type:label scope:global _savegpr_29 = .text:0x803455D4; // type:label scope:global _savegpr_30 = .text:0x803455D8; // type:label scope:global _savegpr_31 = .text:0x803455DC; // type:label scope:global -__restore_gpr = .text:0x803455E4; // type:function size:0x4C +__restore_gpr = .text:0x803455E4; // type:function size:0x4C scope:global _restgpr_14 = .text:0x803455E4; // type:label scope:global _restgpr_15 = .text:0x803455E8; // type:label scope:global _restgpr_16 = .text:0x803455EC; // type:label scope:global @@ -15563,19 +15563,19 @@ fn_80345AB4 = .text:0x80345AB4; // type:function size:0xB4 fn_80345B68 = .text:0x80345B68; // type:function size:0xCC __fini_cpp_exceptions = .text:0x80345C34; // type:function size:0x34 scope:global __init_cpp_exceptions = .text:0x80345C68; // type:function size:0x3C scope:global -ExPPC_LongJump__FP12ThrowContextPvPv = .text:0x80345CA4; // type:function size:0x104 -__throw = .text:0x80345DA8; // type:function size:0x144 -__end__catch = .text:0x80345EEC; // type:function size:0x44 -ExPPC_ThrowHandler__FP12ThrowContext = .text:0x80345F30; // type:function size:0x410 -__unexpected = .text:0x80346340; // type:function size:0x1B4 -__dt__Q23std13bad_exceptionFv = .text:0x803464F4; // type:function size:0x5C -ExPPC_UnwindStack__FP12ThrowContextP15MWExceptionInfoPv = .text:0x80346550; // type:function size:0x50C -ExPPC_PopStackFrame__FP12ThrowContextP15MWExceptionInfo = .text:0x80346A5C; // type:function size:0x248 -ExPPC_NextAction__FP14ActionIterator = .text:0x80346CA4; // type:function size:0x1C0 -ExPPC_FindExceptionRecord__FPcP15MWExceptionInfo = .text:0x80346E64; // type:function size:0x204 +ExPPC_LongJump__FP12ThrowContextPvPv = .text:0x80345CA4; // type:function size:0x104 scope:local +__throw = .text:0x80345DA8; // type:function size:0x144 scope:global +__end__catch = .text:0x80345EEC; // type:function size:0x44 scope:global +ExPPC_ThrowHandler__FP12ThrowContext = .text:0x80345F30; // type:function size:0x410 scope:local +__unexpected = .text:0x80346340; // type:function size:0x1B4 scope:global +__dt__Q23std13bad_exceptionFv = .text:0x803464F4; // type:function size:0x5C scope:weak +ExPPC_UnwindStack__FP12ThrowContextP15MWExceptionInfoPv = .text:0x80346550; // type:function size:0x50C scope:local +ExPPC_PopStackFrame__FP12ThrowContextP15MWExceptionInfo = .text:0x80346A5C; // type:function size:0x248 scope:local +ExPPC_NextAction__FP14ActionIterator = .text:0x80346CA4; // type:function size:0x1C0 scope:local +ExPPC_FindExceptionRecord__FPcP15MWExceptionInfo = .text:0x80346E64; // type:function size:0x204 scope:local __unregister_fragment = .text:0x80347068; // type:function size:0x34 scope:global __register_fragment = .text:0x8034709C; // type:function size:0x34 scope:global -what__Q23std13bad_exceptionCFv = .text:0x803470D0; // type:function size:0xC align:0x4 +what__Q23std13bad_exceptionCFv = .text:0x803470D0; // type:function size:0xC scope:weak align:0x4 exit = .text:0x803470DC; // type:function size:0xF0 scope:global fn_803471CC = .text:0x803471CC; // type:function size:0x9C fn_80347268 = .text:0x80347268; // type:function size:0x70 diff --git a/config/G2MJ01/config.yml b/config/G2MJ01/config.yml new file mode 100644 index 0000000..6ec8d95 --- /dev/null +++ b/config/G2MJ01/config.yml @@ -0,0 +1,3 @@ +object: orig/G2MJ01/sys/main.dol +splits: config/G2MJ01/splits.txt +symbols: config/G2MJ01/symbols.txt diff --git a/config/G2MP01/config.yml b/config/G2MP01/config.yml new file mode 100644 index 0000000..ae1b193 --- /dev/null +++ b/config/G2MP01/config.yml @@ -0,0 +1,3 @@ +object: orig/G2MP01/sys/main.dol +splits: config/G2MP01/splits.txt +symbols: config/G2MP01/symbols.txt diff --git a/configure.py b/configure.py index c089947..bb6b86c 100644 --- a/configure.py +++ b/configure.py @@ -19,8 +19,8 @@ LIBS = [ "host": True, "objects": [ ["MetroidPrime/Player/CPlayerState.cpp", False], - ] - } + ], + }, ] VERSIONS = [ "G2ME01", # 0 @@ -32,6 +32,7 @@ import os import io import sys import argparse +import json from pathlib import Path from shutil import which @@ -39,7 +40,9 @@ import typing from tools import ninja_syntax -def path(input: typing.Union[typing.List[Path], Path, None]) -> typing.Optional[typing.List[str]]: +def path( + input: typing.Union[typing.List[Path], Path, None] +) -> typing.Optional[typing.List[str]]: if input is None: return None elif isinstance(input, list): @@ -254,7 +257,7 @@ n.comment("Source files") src_path = Path("src") asm_path = Path("asm") build_src_path = build_path / "src" -units_path = build_path / "units.txt" +build_config_path = build_path / "config.json" def locate_unit(unit): @@ -266,15 +269,16 @@ def locate_unit(unit): has_units = False -if units_path.is_file(): +if build_config_path.is_file(): has_units = True src_path = Path("src") link_inputs = [] used_compiler_versions = set() - with open(units_path) as r: - for line in r: - obj_path, unit = line.rstrip().split(":", 2) + with open(build_config_path) as r: + data = json.load(r) + for unit in data["units"]: + obj_path, unit = unit["object"], unit["name"] unit_path = src_path / unit if unit_path.exists(): result = locate_unit(unit) @@ -396,25 +400,20 @@ if units_path.is_file(): # DOL split ### n.comment("Generate objects from original DOL") -dol_path = args.orig / version / "sys" / "main.dol" -config_path = Path("config") / version -splits_path = config_path / "splits.txt" -symbols_path = config_path / "symbols.txt" +config_path = Path("config") / version / "config.yml" n.rule( name="split", - command=f"{dtk} dol split $in $out -p $splits -s $symbols --no-update", + command=f"{dtk} dol split $in $out_dir", description="SPLIT $in", + depfile="$out_dir/dep", + deps="gcc", ) n.build( - inputs=path(dol_path), - outputs=path(build_path), + inputs=path(config_path), + outputs=path(build_config_path), rule="split", - implicit=path([dtk, splits_path, symbols_path]), - implicit_outputs=path(units_path), - variables={ - "splits": splits_path, - "symbols": symbols_path, - }, + implicit=path(dtk), + variables={"out_dir": path(build_path)}, ) n.newline() @@ -432,7 +431,7 @@ n.rule( n.build( outputs="build.ninja", rule="configure", - implicit=path([script, tools_path / "ninja_syntax.py", build_path]), + implicit=path([script, tools_path / "ninja_syntax.py", build_config_path]), ) n.newline() @@ -443,7 +442,7 @@ n.comment("Default rule") if has_units: n.default(path(build_path / "main.dol.ok")) else: - n.default(path(build_path)) + n.default(path(build_config_path)) ### # Write build.ninja diff --git a/orig/G2ME01/.gitkeep b/orig/G2ME01/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/orig/G2MJ01/.gitkeep b/orig/G2MJ01/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/orig/G2MP01/.gitkeep b/orig/G2MP01/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tools/dtk_version b/tools/dtk_version index 937cd78..7becae1 100644 --- a/tools/dtk_version +++ b/tools/dtk_version @@ -1 +1 @@ -v0.3.1 +v0.3.2