1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-04 08:46:07 +00:00
oot/tools/disasm/list_generated_files.py

63 lines
1.9 KiB
Python
Raw Normal View History

Set up disassembly for gc-eu-mq (#1613) * Disassemble gc-eu-mq * Add script to report progress with matching * Fix whitespace * Change T|None to typing.Optional[T] * Use typing.List * More type annotations fixes for old Python versions * Fix type errors * More type annotations * Use typing.Iterator * Use $(PYTHON) for disassembly * Don't use grouped targets to support very old Make versions * Docs: suggest checking MM, mention virtualenv, clarify about expected/ * Update sym_info.py Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Sync functions.txt * Start banned symbol range at 0x10000000 * Also ban symbols from 0xC0000000-0xFFFFFFFF * Unban IPL symbols * Fix first_diff.py * Sync z_collision_check functions.txt * Ban 0xA0 symbols too * Touch .disasm sentinel file * Copy -jN comment in docs * diff.py flags: remove -3, add -s * Update docs/retail_versions.md Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> * Comment that segments are still from the Debug ROM * Revert "diff.py flags: remove -3, add -s" This reverts commit bfaae66c1d02719e706734be9503e78d2b3f104b. * Apply suggestions from code review Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Remove #ifdef example * Reformat Python files with black * Add copyright notice to new Python files * Add TODOs to Makefile --------- Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
2024-01-28 17:09:03 +00:00
#!/usr/bin/env python3
# SPDX-FileCopyrightText: © 2024 ZeldaRET
# SPDX-License-Identifier: CC0-1.0
import argparse
import csv
from pathlib import Path
from file_addresses import parse_file_addresses, get_z_name_for_overlay
def main():
parser = argparse.ArgumentParser(
description="List generated files for the Makefile."
)
parser.add_argument(
"-o", "--output-dir", help="Output directory", type=Path, required=True
)
parser.add_argument(
"--config-dir", help="Config directory", type=Path, required=True
)
args = parser.parse_args()
if not args.config_dir.exists(): # disassembly is not set up for this version
return
file_addresses = parse_file_addresses(args.config_dir / "file_addresses.csv")
generated_files = set()
for dma_file in file_addresses:
file_splits_path = args.config_dir / f"files_{dma_file.name}.csv"
if file_splits_path.exists():
with open(file_splits_path) as f:
reader = csv.reader(f)
for row in reader:
if (
not row # blank line
or row[2].startswith(".") # section name or .end
or row[2].endswith(
"_reloc.s"
) # TODO: disassemble overlay reloc sections?
):
continue
generated_files.add(row[2])
elif dma_file.overlay_dir is not None:
z_name = get_z_name_for_overlay(dma_file.name)
generated_files.add(
f"src/overlays/{dma_file.overlay_dir}/{dma_file.name}/{z_name}.s"
)
else:
raise Exception(
f"DMA file {dma_file.name} is not an overlay but has no file splits"
)
for filename in sorted(generated_files):
print(args.output_dir / filename)
if __name__ == "__main__":
main()