summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2016-04-10 19:19:58 -0400
committeryenatch <yenatch@gmail.com>2016-04-10 19:19:58 -0400
commit05cffac7448a46468a70d21104a53110fd7c3a00 (patch)
tree388779553483b94417f25eec43ee085082d2ec8d
parentd257188282e932380de4e1b1a46758a1bc9c8cd6 (diff)
Add a custom scan_includes.py.
-rw-r--r--Makefile3
-rw-r--r--scan_includes.py35
2 files changed, 36 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 67eed8ad8..27e345d2f 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,8 @@ MD5 := md5sum -c --quiet
.SECONDEXPANSION:
.PRECIOUS: %.2bpp %.1bpp
-poketools := extras/pokemontools
gfx := $(PYTHON) gfx.py
-includes := $(PYTHON) $(poketools)/scan_includes.py
+includes := $(PYTHON) scan_includes.py
crystal_obj := \
diff --git a/scan_includes.py b/scan_includes.py
new file mode 100644
index 000000000..60929d3fe
--- /dev/null
+++ b/scan_includes.py
@@ -0,0 +1,35 @@
+#!/bin/python
+# coding: utf-8
+
+"""
+Recursively scan an asm file for dependencies.
+"""
+
+import sys
+import argparse
+
+includes = set()
+
+def scan_file(filename):
+ for line in open(filename):
+ if 'INC' not in line:
+ continue
+ line = line.split(';')[0]
+ if 'INCLUDE' in line:
+ include = line.split('"')[1]
+ includes.add(include)
+ scan_file(include)
+ elif 'INCBIN' in line:
+ include = line.split('"')[1]
+ includes.add(include)
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('filenames', nargs='*')
+ args = ap.parse_args()
+ for filename in set(args.filenames):
+ scan_file(filename)
+ sys.stdout.write(' '.join(includes))
+
+if __name__ == '__main__':
+ main()