2013-09-10 22:20:52 -07:00
|
|
|
# coding: utf-8
|
|
|
|
|
2013-09-10 22:40:53 -07:00
|
|
|
"""
|
|
|
|
Recursively scan an asm file for rgbasm INCLUDEs and INCBINs.
|
2013-12-02 20:31:16 -08:00
|
|
|
Used to generate dependencies for each rgbasm object.
|
2013-09-10 22:40:53 -07:00
|
|
|
"""
|
2013-09-10 22:20:52 -07:00
|
|
|
|
2013-09-11 16:17:25 -07:00
|
|
|
import os
|
2013-09-10 22:20:52 -07:00
|
|
|
import sys
|
|
|
|
|
2013-12-02 20:31:16 -08:00
|
|
|
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(include, includes)
|
|
|
|
break
|
|
|
|
return includes
|
2013-09-10 22:20:52 -07:00
|
|
|
|
2013-12-02 20:31:16 -08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
filenames = sys.argv[1:]
|
|
|
|
for filename in filenames:
|
|
|
|
sys.stdout.write(' '.join(recursive_scan(filename)))
|
2013-09-10 22:20:52 -07:00
|
|
|
|