-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.py
118 lines (75 loc) · 2.84 KB
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
import subprocess
import glob
from multiprocessing import Pool
import traceback
AAF_ROOT = os.environ.get('AAFSDK_ROOT','/Users/mark/Dev/aaf/aaf-git/AAFx86_64DarwinSDK/g++')
aaf_include_dirs = ['./include',
'./axLib',
os.path.join(AAF_ROOT, 'include'),
]
def run_cmd(cmd):
#print subprocess.list2cmdline(cmd)
stdout = None
stderr = None
try:
p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
stdout,stderr = p.communicate()
except:
print traceback.format_exc()
return cmd,stdout,stderr
def find_aaf_header():
for d in aaf_include_dirs:
aaf_header = os.path.join(d,'AAF.h')
if os.path.exists(aaf_header):
return aaf_header
def run_gen(docs=False):
working_dir = 'pyste_src'
cmd = ['python','gen_smartpointers.py']
print subprocess.list2cmdline(cmd)
subprocess.check_call(cmd,cwd=working_dir)
cmd = ['python','gen_iterators.py']
print subprocess.list2cmdline(cmd)
subprocess.check_call(cmd,cwd=working_dir)
cmd = ['python','gen_implicitly_convertible.py']
print subprocess.list2cmdline(cmd)
subprocess.check_call(cmd,cwd=working_dir)
aaf_header_path = find_aaf_header()
if aaf_header_path and docs:
cmd = ['python','docs/parse_aaf_header.py',aaf_header_path,'pyaaf/docs.pkl']
print subprocess.list2cmdline(cmd)
subprocess.check_call(cmd)
else:
print "skipping docstring generation"
def run_pyste(pyste_files=None):
if not pyste_files:
pyste_files = glob.glob('./pyste_src/*.pyste')
all_pyste_files = glob.glob('./pyste_src/*.pyste')
includes = []
commands = []
for item in aaf_include_dirs:
includes.extend(['-I',item])
cmd = ['pyste.py', '--module=core', '--multiple', '--generate-main', '--out=./src']
cmd.extend(includes)
cmd.extend(all_pyste_files)
commands.append(cmd)
for item in pyste_files:
cmd = ['pyste.py', '--module=core', '--multiple' ,'--out=./src']
cmd.extend(includes)
cmd.append(item)
commands.append(cmd)
p = Pool()
for cmd,stdout,stderr in p.imap_unordered(run_cmd,commands):
print subprocess.list2cmdline(cmd)
print stdout
#print stderr
p.close()
p.join()
if __name__ == "__main__":
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-d','--docstrings',action="store_true", default=False,
help="parse AAF.h and gerate docstrings")
(options, args) = parser.parse_args()
run_gen(options.docstrings)
run_pyste(args)