1 |
# Extensions to Scons |
2 |
|
3 |
import py_compile |
4 |
import sys |
5 |
import os |
6 |
|
7 |
# Code to build .pyc from .py |
8 |
def build_py(target, source, env): |
9 |
py_compile.compile(str(source[0]), str(target[0])) |
10 |
return None |
11 |
|
12 |
# Code to run unit_test executables |
13 |
def runUnitTest(target, source, env): |
14 |
app = str(source[0].abspath) |
15 |
if not os.system(app): |
16 |
open(str(target[0]),'w').write("PASSED\n") |
17 |
else: |
18 |
return 1 |
19 |
return None |
20 |
|
21 |
def runPyUnitTest(target, source, env): |
22 |
app = 'python '+str(source[0].abspath) |
23 |
if not os.system(app): |
24 |
open(str(target[0]),'w').write("PASSED\n") |
25 |
else: |
26 |
return 1 |
27 |
return None |
28 |
|
29 |
# code to build epydoc docs |
30 |
def build_epydoc(target, source, env): |
31 |
# get where I am currently, just as a reference |
32 |
pwd = os.getcwd() |
33 |
|
34 |
# get the full path of the runepydoc script |
35 |
runepydoc = str(source[0].abspath) |
36 |
|
37 |
# use this path to work out where the doc directory is |
38 |
dirs = runepydoc.split('/') |
39 |
dirs = dirs[:-3] # trim the last two entries: this is now the doc dir path |
40 |
docdir = '/'.join(dirs) # this is the backwards python way to do it |
41 |
# (I'm feeling in a perl mood today...) |
42 |
|
43 |
# change into the relevant dir |
44 |
os.chdir(docdir) |
45 |
|
46 |
# run the epydoc script |
47 |
if not os.system(runepydoc): |
48 |
os.chdir(pwd) |
49 |
open(str(target[0]), 'w').write("Documentation built\n") |
50 |
else: |
51 |
return 1 |
52 |
return None |
53 |
|
54 |
# build doxygen docs |
55 |
def build_doxygen(target, source, env): |
56 |
# get where I am currently, just as a reference |
57 |
pwd = os.getcwd() |
58 |
|
59 |
# get the full path of the rundoxygen script |
60 |
rundoxygen = str(source[0].abspath) |
61 |
|
62 |
# use this path to work out where the doc directory is |
63 |
dirs = rundoxygen.split('/') |
64 |
dirs = dirs[:-2] # trim the last two entries: this is now the doc dir path |
65 |
docdir = '/'.join(dirs) # this is the backwards python way to do it |
66 |
# (I'm feeling in a perl mood today...) |
67 |
|
68 |
# change into the relevant dir |
69 |
os.chdir(docdir) |
70 |
|
71 |
# run the doxygen script |
72 |
if not os.system(rundoxygen): |
73 |
os.chdir(pwd) |
74 |
open(str(target[0]), 'w').write("Documentation built\n") |
75 |
else: |
76 |
return 1 |
77 |
return None |