-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile.py
50 lines (33 loc) · 956 Bytes
/
compile.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
#!/usr/bin/python
import os, sys
HERE = os.path.abspath(os.path.dirname(sys.argv[0]))
def pathto(x):
return os.path.join(HERE, x)
NAME = 'template'
DIRECTORY = pathto('example/')
BUILD_DIR = pathto('example/build/')
EXECUTABLE = pathto('pyserf.py')
if len(sys.argv) > 1:
NAME = sys.argv[1]
os.system("cd %s && %s %s.py -s -f && python setup.py build" %
(DIRECTORY, EXECUTABLE, NAME))
sys.path.extend([ BUILD_DIR + x for x in os.listdir(BUILD_DIR)
if x.startswith('lib') ])
print sys.path
exec("import %s as testmod" % NAME)
print "\nimported %s" % testmod
for a in dir(testmod):
print getattr(testmod, a)
try:
print getattr(testmod, a)()
except TypeError:
pass
if hasattr(testmod, 'selftest'):
print "found selftest, running"
testmod.selftest()
if NAME == 'template':
print testmod.foo
x = testmod.bar()
print testmod.bar.baz
print x.baz(1)
del x