1 |
# Extensions to Scons |
2 |
def build_py(target, source, env): |
3 |
# Code to build .pyc from .py |
4 |
import py_compile, sys; |
5 |
py_compile.compile(str(source[0]), str(target[0])) |
6 |
return None |
7 |
|
8 |
def runUnitTest(target, source, env): |
9 |
import os |
10 |
app = str(source[0].abspath) |
11 |
if not os.system(app): |
12 |
open(str(target[0]),'w').write("PASSED\n") |
13 |
return None |
14 |
|
15 |
def runPyUnitTest(target, source, env): |
16 |
import os |
17 |
app = 'python '+str(source[0].abspath) |
18 |
if not os.system(app): |
19 |
open(str(target[0]),'w').write("PASSED\n") |
20 |
return None |
21 |
|
22 |
|
23 |
#import fnmatch |
24 |
#import os |
25 |
|
26 |
#def Glob( includes = Split( '*' ), excludes = None, dir = '.'): |
27 |
# """Similar to glob.glob, except globs SCons nodes, and thus sees |
28 |
# generated files and files from build directories. Basically, it sees |
29 |
# anything SCons knows about. A key subtlety is that since this function |
30 |
# operates on generated nodes as well as source nodes on the filesystem, |
31 |
# it needs to be called after builders that generate files you want to |
32 |
# include. |
33 |
# |
34 |
# It will return both Dir entries and File entries |
35 |
# """ |
36 |
# def fn_filter(node): |
37 |
# fn = os.path.basename(str(node)) |
38 |
# match = 0 |
39 |
# for include in includes: |
40 |
# if fnmatch.fnmatchcase( fn, include ): |
41 |
# match = 1 |
42 |
# break |
43 |
# |
44 |
# if match == 1 and not excludes is None: |
45 |
# for exclude in excludes: |
46 |
# if fnmatch.fnmatchcase( fn, exclude ): |
47 |
# match = 0 |
48 |
# break |
49 |
# |
50 |
# return match |
51 |
# |
52 |
# def filter_nodes(where): |
53 |
# children = filter(fn_filter, where.all_children()) |
54 |
# nodes = [] |
55 |
# for f in children: |
56 |
# nodes.append(gen_node(f)) |
57 |
# return nodes |
58 |
# |
59 |
# def gen_node(n): |
60 |
# """Checks first to see if the node is a file or a dir, then |
61 |
# creates the appropriate node. [code seems redundant, if the node |
62 |
# is a node, then shouldn't it just be left as is? |
63 |
# """ |
64 |
# if type(n) in (type(''), type(u'')): |
65 |
# path = n |
66 |
# else: |
67 |
# path = n.abspath |
68 |
# if os.path.isdir(path): |
69 |
# return Dir(n) |
70 |
# else: |
71 |
# return File(n) |
72 |
# |
73 |
# here = Dir(dir) |
74 |
# nodes = filter_nodes(here) |
75 |
# |
76 |
# node_srcs = [n.srcnode() for n in nodes] |
77 |
# |
78 |
# src = here.srcnode() |
79 |
# if src is not here: |
80 |
# for s in filter_nodes(src): |
81 |
# if s not in node_srcs: |
82 |
# # Probably need to check if this node is a directory |
83 |
# nodes.append(gen_node(os.path.join(dir,os.path.basename(str(s))))) |
84 |
# |
85 |
# return nodes |