1 | #!/usr/bin/env python2
|
2 | from __future__ import print_function
|
3 | """
|
4 | c_module_srcs.py
|
5 | """
|
6 |
|
7 | import os
|
8 | import glob
|
9 | import sys
|
10 |
|
11 |
|
12 | def main(argv):
|
13 | manifest_path = argv[1]
|
14 | discovered = argv[2]
|
15 |
|
16 | manifest = {}
|
17 | with open(manifest_path) as f:
|
18 | for line in f:
|
19 | line = line.strip()
|
20 | mod_name, rel_path = line.split(None, 2)
|
21 | manifest[mod_name] = rel_path
|
22 |
|
23 | #print manifest
|
24 | with open(discovered) as f:
|
25 | for line in f:
|
26 | line = line.strip()
|
27 | mod_name, _ = line.split(None, 2)
|
28 |
|
29 | # Hard-coded special cases for now.
|
30 |
|
31 | if mod_name in ('libc', 'fastlex', 'line_input'): # Our own modules
|
32 | # Relative to Python-2.7.13 dir
|
33 | print('../pyext/%s.c' % mod_name)
|
34 |
|
35 | elif mod_name == 'fanos':
|
36 | print('../pyext/%s.c' % mod_name)
|
37 | print('../cpp/fanos_shared.c')
|
38 |
|
39 | elif mod_name == 'fastfunc':
|
40 | print('../pyext/%s.c' % mod_name)
|
41 | print('../data_lang/j8_libc.c')
|
42 |
|
43 | elif mod_name == 'posix_':
|
44 | print('../pyext/posixmodule.c')
|
45 |
|
46 | elif mod_name == 'math':
|
47 | print('Modules/mathmodule.c')
|
48 | print('Modules/_math.c')
|
49 |
|
50 | # Hm OPy needs these for hashlib in 'opy dis-md5'. OK fine.
|
51 | elif mod_name == '_md5':
|
52 | print('Modules/md5module.c')
|
53 | print('Modules/md5.c')
|
54 | elif mod_name == '_sha':
|
55 | print('Modules/shamodule.c')
|
56 | elif mod_name == '_sha256':
|
57 | print('Modules/sha256module.c')
|
58 | elif mod_name == '_sha512':
|
59 | print('Modules/sha512module.c')
|
60 |
|
61 | elif mod_name == '_io':
|
62 | # This data is in setup.py and Modules/Setup.dist.
|
63 | #_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c
|
64 | # _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c
|
65 | # _io/textio.c
|
66 | print('Modules/_io/bufferedio.c')
|
67 | print('Modules/_io/bytesio.c')
|
68 | print('Modules/_io/fileio.c')
|
69 | print('Modules/_io/iobase.c')
|
70 | print('Modules/_io/_iomodule.c')
|
71 | print('Modules/_io/stringio.c')
|
72 | print('Modules/_io/textio.c')
|
73 |
|
74 | elif mod_name == 'yajl':
|
75 | # Not including headers
|
76 | globs = [
|
77 | 'py-yajl/*.c',
|
78 | 'py-yajl/yajl/src/*.c',
|
79 | ]
|
80 | paths = []
|
81 | for g in globs:
|
82 | paths.extend(glob.glob(g))
|
83 | for path in paths:
|
84 | # UNUSED file. It's an optional layer on top.
|
85 | if os.path.basename(path) == 'yajl_tree.c':
|
86 | continue
|
87 | print('../' + path)
|
88 |
|
89 | else:
|
90 | print(manifest[mod_name])
|
91 |
|
92 |
|
93 | if __name__ == '__main__':
|
94 | try:
|
95 | main(sys.argv)
|
96 | except RuntimeError as e:
|
97 | print('FATAL: %s' % e, file=sys.stderr)
|
98 | sys.exit(1)
|