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.
|
|
|
|
This is used to generate dependencies for each rgbasm object file.
|
|
|
|
"""
|
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
|
|
|
|
|
|
|
|
def scan_for_includes(filename):
|
|
|
|
filenames = []
|
2013-09-11 16:17:25 -07:00
|
|
|
if os.path.exists(filename):
|
|
|
|
for line in open(filename, 'r').readlines():
|
2013-09-10 22:20:52 -07:00
|
|
|
if 'INCLUDE' in line or 'INCBIN' in line:
|
2013-09-11 16:17:25 -07:00
|
|
|
line = line.split(';')[0]
|
|
|
|
if 'INCLUDE' in line or 'INCBIN' in line:
|
|
|
|
filenames += [line.split('"')[1]]
|
2013-09-10 22:20:52 -07:00
|
|
|
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)))
|
|
|
|
|