diff options
author | yenatch <yenatch@gmail.com> | 2014-02-06 19:58:21 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2014-02-06 19:58:21 -0500 |
commit | b18976e8edc2450a5b589457bbeea0854a2ac5e4 (patch) | |
tree | 19b729371dfce6303751d780432ee6adfa08a03d /pokemontools/scan_includes.py | |
parent | 2a44f6e448983c59afa3cb043a50d4f4cb35d37c (diff) | |
parent | 61b83803be9ccdcdcd95b7f8ea7accafab8d4d4d (diff) |
Merge branch 'kanzure/master' into merge-old-commits
Conflicts:
pokemontools/map_editor.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)) + |