| 1 | #!/usr/bin/env python
 | 
| 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 |   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 | 
 | 
| 35 | if __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)
 |