blob: fea70021074bcce843adfe7e96f58563c0484edd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/python
# coding: utf-8
"""
Recursively scan an asm file for dependencies.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import argparse
import os.path
def scan_file(filename):
with open(filename) as f:
for line in f:
if 'INC' not in line:
continue
line = line.split(';')[0]
if 'INCLUDE' in line:
include = line.split('"')[1]
if os.path.exists("src/"):
yield "src/" + include
for inc in scan_file("src/" + include):
yield inc
else:
yield include
for inc in scan_file(include):
yield inc
elif 'INCBIN' in line:
include = line.split('"')[1]
if 'baserom.gbc' not in line and os.path.exists("src/"):
yield "src/" + include
else:
yield include
def main():
ap = argparse.ArgumentParser()
ap.add_argument('filenames', nargs='*')
args = ap.parse_args()
includes = set()
for filename in set(args.filenames):
includes.update(scan_file(filename))
sys.stdout.write(' '.join(sorted(includes)))
if __name__ == '__main__':
main()
|