OILS / build / c_module_toc.py View on Github | oils.pub

49 lines, 32 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3"""
4c_module_toc.py
5"""
6
7import glob
8import re
9import sys
10
11
12PURE_C_RE = re.compile(r'.*/(.*)module\.c$')
13HELPER_C_RE = re.compile(r'.*/(.*)\.c$')
14
15
16def 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
44if __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)