-
Notifications
You must be signed in to change notification settings - Fork 34
/
check_exports.py
39 lines (32 loc) · 1.05 KB
/
check_exports.py
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
import sys
import re
if len(sys.argv) < 2:
print("Usage:\n {} <template> <undef file>".format(sys.argv[0]))
exit(1)
fd = re.compile(r"unresolved: `_(\w*)'")
had_errors = False
with open(sys.argv[1], "r") as template:
with open(sys.argv[2], "r") as undeffile:
# create a set with available exports
exports = []
for l in template:
l = l.strip()
if not l.startswith("//") and not l.startswith("#") and len(l) > 0:
exports.append(l)
available = set(exports)
# check if all symbols exist
for l in undeffile:
res = fd.search(l)
if res:
func = res.group(1)
if not func.startswith("js_"):
if func not in exports:
had_errors = True
print("WARNING: DXE export '{}' missing!".format(func))
# fail if there were missing symbols
if had_errors:
print("\n\n!!! DXE export check FAILED!\n\n")
exit(1)
else:
print("DXE export check OK!")
exit(0)