diff options
author | xCrystal <rgr.crystal@gmail.com> | 2018-06-12 14:12:32 +0200 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2018-06-12 14:12:32 +0200 |
commit | 9ec77a8f48c6e986e803030ada06da31fae85370 (patch) | |
tree | 3b6e7cb96625d262c6a21509b2cac4e530bfcf6f /tools/scan_includes.py | |
parent | eb954b0364e04df40c571817cb6092390a7e716f (diff) |
Don't use the extras submodule
Most tools from pokemon-reverse-engineering-tools are meant for pokecrystal or pokered. Having only the subset of required tools without depending on a submodule makes it easier to submit custom changes exclusive poketcg and its structure. For example, the disasm tool can be made to use poketcg rom/sym files by default, read vram and hram as symbols, and can be modified in the future to for example guess text labels in applicable load instructions or to dump poketcg-specific scripts. gfx.py was also added, but without the not required pokecrystal lz (de)compression support
Diffstat (limited to 'tools/scan_includes.py')
-rw-r--r-- | tools/scan_includes.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/scan_includes.py b/tools/scan_includes.py new file mode 100644 index 0000000..53ff091 --- /dev/null +++ b/tools/scan_includes.py @@ -0,0 +1,43 @@ +#!/bin/python +# coding: utf-8 + +""" +Recursively scan an asm file for dependencies. +""" + +import sys +import argparse +import os.path + +includes = set() + +def scan_file(filename): + for line in open(filename): + if 'INC' not in line: + continue + line = line.split(';')[0] + if 'INCLUDE' in line: + include = line.split('"')[1] + if os.path.exists("src/"): + includes.add("src/" + include) + scan_file("src/" + include) + else: + includes.add(include) + scan_file(include) + elif 'INCBIN' in line: + include = line.split('"')[1] + if 'baserom.gbc' not in line and os.path.exists("src/"): + includes.add("src/" + include) + else: + includes.add(include) + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('filenames', nargs='*') + args = ap.parse_args() + for filename in set(args.filenames): + scan_file(filename) + sys.stdout.write(' '.join(includes)) + +if __name__ == '__main__': + main() |