mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-04-25 15:57:07 -05:00
use file includes in rgbasm objects to generate dependencies
This commit is contained in:
parent
0fd121a81e
commit
806fd657c2
34
pokemontools/scan_includes.py
Normal file
34
pokemontools/scan_includes.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# 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(include, includes)
|
||||
break
|
||||
return includes
|
||||
|
||||
if __name__ == '__main__':
|
||||
filenames = sys.argv[1:]
|
||||
for filename in filenames:
|
||||
dependencies = recursive_scan(os.path.join(conf.path, filename))
|
||||
sys.stdout.write(' '.join(dependencies))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user