1 | #!/usr/bin/env python2
|
2 | from __future__ import print_function
|
3 | """
|
4 | c_module_toc.py
|
5 | """
|
6 |
|
7 | import glob
|
8 | import re
|
9 | import sys
|
10 |
|
11 |
|
12 | PURE_C_RE = re.compile(r'.*/(.*)module\.c$')
|
13 | HELPER_C_RE = re.compile(r'.*/(.*)\.c$')
|
14 |
|
15 |
|
16 | def main(argv):
|
17 | # module name -> list of paths to include
|
18 | c_module_srcs = {}
|
19 |
|
20 | globs = [
|
21 | 'Modules/*.c',
|
22 | 'Modules/_io/*.c',
|
23 | # The main entry point
|
24 | '../py-yajl/yajl.c',
|
25 | ]
|
26 |
|
27 | paths = []
|
28 | for g in globs:
|
29 | paths.extend(glob.glob(g))
|
30 |
|
31 | for c_path in paths:
|
32 | m = PURE_C_RE.match(c_path)
|
33 | if m:
|
34 | print(m.group(1), c_path)
|
35 | continue
|
36 |
|
37 | m = HELPER_C_RE.match(c_path)
|
38 | if m:
|
39 | name = m.group(1)
|
40 | # Special case:
|
41 | if name == '_hashopenssl':
|
42 | name = '_hashlib'
|
43 | print(name, c_path)
|
44 |
|
45 |
|
46 | if __name__ == '__main__':
|
47 | try:
|
48 | main(sys.argv)
|
49 | except RuntimeError as e:
|
50 | print('FATAL: %s' % e, file=sys.stderr)
|
51 | sys.exit(1)
|