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 | ]
|
24 |
|
25 | paths = []
|
26 | for g in globs:
|
27 | paths.extend(glob.glob(g))
|
28 |
|
29 | for c_path in paths:
|
30 | m = PURE_C_RE.match(c_path)
|
31 | if m:
|
32 | print(m.group(1), c_path)
|
33 | continue
|
34 |
|
35 | m = HELPER_C_RE.match(c_path)
|
36 | if m:
|
37 | name = m.group(1)
|
38 | # Special case:
|
39 | if name == '_hashopenssl':
|
40 | name = '_hashlib'
|
41 | print(name, c_path)
|
42 |
|
43 |
|
44 | if __name__ == '__main__':
|
45 | try:
|
46 | main(sys.argv)
|
47 | except RuntimeError as e:
|
48 | print('FATAL: %s' % e, file=sys.stderr)
|
49 | sys.exit(1)
|