diff options
author | yenatch <yenatch@gmail.com> | 2013-12-20 00:43:30 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-12-21 00:37:35 -0500 |
commit | efe0b717ef21acde2d30fc7de580547738ca67d6 (patch) | |
tree | 524c63520cc852d4244a899ec08d5e39b517cec8 /pokemontools/scan_includes.py | |
parent | 973a78167b104479bb6c8c4c528ae914106b1b53 (diff) | |
parent | f0aaf3cd568c485af40690ce0f18a6cd456ed02e (diff) |
Merge remote-tracking branch 'kanzure/master' into battle-animations
Conflicts:
pokemontools/wram.py
Diffstat (limited to 'pokemontools/scan_includes.py')
-rw-r--r-- | pokemontools/scan_includes.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pokemontools/scan_includes.py b/pokemontools/scan_includes.py new file mode 100644 index 0000000..7f34e92 --- /dev/null +++ b/pokemontools/scan_includes.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" +Recursively scan an asm file for rgbasm INCLUDEs and INCBINs. +Used to generate dependencies for each rgbasm object. +""" + +import os +import sys + +import configuration +conf = configuration.Config() + +def recursive_scan(filename, includes = []): + if (filename[-4:] == '.asm' or filename[-3] == '.tx') and os.path.exists(filename): + lines = open(filename).readlines() + for line in lines: + for directive in ('INCLUDE', 'INCBIN'): + if directive in line: + line = line[:line.find(';')] + if directive in line: + include = line.split('"')[1] + if include not in includes: + includes += [include] + includes = recursive_scan(os.path.join(conf.path, include), includes) + break + return includes + +if __name__ == '__main__': + filenames = sys.argv[1:] + dependencies = [] + for filename in filenames: + dependencies += recursive_scan(os.path.join(conf.path, filename)) + dependencies = list(set(dependencies)) + sys.stdout.write(' '.join(dependencies)) + |