OILS / opy / _regtest / src / build / c_module_toc.py View on Github | oilshell.org

40 lines, 25 significant
1#!/usr/bin/env python
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 for c_path in glob.glob('Modules/*.c') + glob.glob('Modules/_io/*.c'):
21 m = PURE_C_RE.match(c_path)
22 if m:
23 print(m.group(1), c_path)
24 continue
25
26 m = HELPER_C_RE.match(c_path)
27 if m:
28 name = m.group(1)
29 # Special case:
30 if name == '_hashopenssl':
31 name = '_hashlib'
32 print(name, c_path)
33
34
35if __name__ == '__main__':
36 try:
37 main(sys.argv)
38 except RuntimeError as e:
39 print('FATAL: %s' % e, file=sys.stderr)
40 sys.exit(1)