diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-09-10 22:47:24 -0700 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-09-10 22:47:24 -0700 |
commit | 18656332b7b4ca67461d4cd4b6b8282d3bc7ab0c (patch) | |
tree | c5edf9bb9811384df6994e85f49d082921223d4f /scan_includes.py | |
parent | 5f6ecb8d1ed1af55ba79e8db342c07368d7f6760 (diff) | |
parent | e11a56a1f654de05043eeefac0061e6d2c1b67ba (diff) |
Merge pull request #202 from yenatch/rgbasm-objects
makefile: support multiple rgbasm objects
Diffstat (limited to 'scan_includes.py')
-rw-r--r-- | scan_includes.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scan_includes.py b/scan_includes.py new file mode 100644 index 000000000..3f006998c --- /dev/null +++ b/scan_includes.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" +Recursively scan an asm file for rgbasm INCLUDEs and INCBINs. +This is used to generate dependencies for each rgbasm object file. +""" + +import sys + +def scan_for_includes(filename): + filenames = [] + for line in open(filename, 'r').readlines(): + if 'INCLUDE' in line or 'INCBIN' in line: + line = line.split(';')[0] + if 'INCLUDE' in line or 'INCBIN' in line: + filenames += [line.split('"')[1]] + return filenames + +def recursive_scan_for_includes(filename): + filenames = [] + if '.asm' in filename or '.tx' in filename: + for include in scan_for_includes(filename): + filenames += [include] + recursive_scan_for_includes(include) + return filenames + +if len(sys.argv) > 1: + for arg in sys.argv[1:]: + sys.stdout.write(' '.join(recursive_scan_for_includes(arg))) + |