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 |
#import fnmatch |
16 |
#import os |
17 |
|
18 |
#def Glob( includes = Split( '*' ), excludes = None, dir = '.'): |
19 |
# """Similar to glob.glob, except globs SCons nodes, and thus sees |
20 |
# generated files and files from build directories. Basically, it sees |
21 |
# anything SCons knows about. A key subtlety is that since this function |
22 |
# operates on generated nodes as well as source nodes on the filesystem, |
23 |
# it needs to be called after builders that generate files you want to |
24 |
# include. |
25 |
# |
26 |
# It will return both Dir entries and File entries |
27 |
# """ |
28 |
# def fn_filter(node): |
29 |
# fn = os.path.basename(str(node)) |
30 |
# match = 0 |
31 |
# for include in includes: |
32 |
# if fnmatch.fnmatchcase( fn, include ): |
33 |
# match = 1 |
34 |
# break |
35 |
# |
36 |
# if match == 1 and not excludes is None: |
37 |
# for exclude in excludes: |
38 |
# if fnmatch.fnmatchcase( fn, exclude ): |
39 |
# match = 0 |
40 |
# break |
41 |
# |
42 |
# return match |
43 |
# |
44 |
# def filter_nodes(where): |
45 |
# children = filter(fn_filter, where.all_children()) |
46 |
# nodes = [] |
47 |
# for f in children: |
48 |
# nodes.append(gen_node(f)) |
49 |
# return nodes |
50 |
# |
51 |
# def gen_node(n): |
52 |
# """Checks first to see if the node is a file or a dir, then |
53 |
# creates the appropriate node. [code seems redundant, if the node |
54 |
# is a node, then shouldn't it just be left as is? |
55 |
# """ |
56 |
# if type(n) in (type(''), type(u'')): |
57 |
# path = n |
58 |
# else: |
59 |
# path = n.abspath |
60 |
# if os.path.isdir(path): |
61 |
# return Dir(n) |
62 |
# else: |
63 |
# return File(n) |
64 |
# |
65 |
# here = Dir(dir) |
66 |
# nodes = filter_nodes(here) |
67 |
# |
68 |
# node_srcs = [n.srcnode() for n in nodes] |
69 |
# |
70 |
# src = here.srcnode() |
71 |
# if src is not here: |
72 |
# for s in filter_nodes(src): |
73 |
# if s not in node_srcs: |
74 |
# # Probably need to check if this node is a directory |
75 |
# nodes.append(gen_node(os.path.join(dir,os.path.basename(str(s))))) |
76 |
# |
77 |
# return nodes |