papermario/tools/sortsymz.py
Ethan Roseman db578d9788
a5dd0 (model file) + filemenu decomp (#420)
* remove some warnings, improve build speed on master

* update Camera

* update_camera_zone_interp not matching but close :/

* cleanup

* configure fix

* cleanup, better gbi macros

* decomp and syms

* a couple more

* 2 more and stuff

* more naming

* 3

* syms

* mdl_get_child_count

* more stuff

* get_model_list_index_from_tree_index

* 5 more

* header org

* update_entity_shadow_position

* fog color funcs

* more color stuff

* display lists

* create_shadow_from_data

* 4 evt shtuffsh

* func_80117D00

* func_80111790

* some BSS

* entity_raycast_down

* MakeEntity and almost step_entity_commandList

* step_current_game_mode

* filemenu stuff

* lots more filemenu stuff

* cleanup

* formatting

* fixes

* 1 more

* more fixes
2021-09-22 20:17:46 +09:00

57 lines
1.6 KiB
Python

import os
syms = []
groups = {}
with open("tools/symz.txt") as f:
for line in f.readlines():
name, addr = line.strip().strip(";").split(" = ")
syms.append((name, int(addr, 0), set()))
# Search src for syms
for root, dirs, files in os.walk("src"):
for file in files:
if file.endswith(".c"):
with open(os.path.join(root, file)) as f:
text = f.read()
for sym in syms:
if sym[0] in text:
sym[2].add(os.path.join(root, file).replace("src/", "")[:-2])
# Search asm for syms
for root, dirs, files in os.walk("ver/us/asm"):
for file in files:
if file.endswith(".s"):
with open(os.path.join(root, file)) as f:
text = f.read()
for sym in syms:
if sym[0] in text:
sym[2].add(root.replace("ver/us/asm/nonmatchings/", ""))
for sym in syms:
if len(sym[2]) == 0:
group = ""
elif len(sym[2]) > 1:
group = "multig"
else:
group = next(iter(sym[2]))
if group not in groups:
groups[group] = []
groups[group].append(sym)
for group in groups:
if group == "":
print("The following symbols can be simply removed from undefined_syms:")
elif group == "multig":
print("The following symbols are found in multiple locations:")
else:
print(group + ":")
sorted_syms = sorted(groups[group], key=lambda tup: tup[1])
for sym in sorted_syms:
print(f"{sym[0]} = 0x{sym[1]:X}")
print()