5 def subdirs(env, *args, **kwargs):
6 for subdir in env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs):
7 if isinstance(subdir, SCons.Node.FS.Dir):
10 def include_child_SConscripts(env, SConscript, first=[]):
11 """Get all the nested SConscripts in that may alter and pass back
12 the environment. They may also add thesis subdependencies to that
15 sdirs = list(subdirs(env, '*'))
16 for subdir in reversed(first): # move first subdirs to the front
19 sdirs.insert(0, subdir)
21 var_sconscript_path = os.path.join(subdir.abspath,
23 src_sconscript_path = os.path.join(subdir.srcnode().abspath,
25 if os.path.exists(src_sconscript_path):
26 if env.GetOption('silent') is False:
27 # ideally 'silent' should be -Q, not the current -s/--silent/--quiet
28 print 'Including', var_sconscript_path
29 env = SConscript(var_sconscript_path, 'env')
32 def check_exec(context, executible):
33 # TODO: context.env vs. context.vardict
34 context.Message('Checking for %s executible...' % executible)
35 if executible.upper() in context.env:
39 for p in context.env.Dictionary()['ENV']['PATH']:
40 path = os.path.join(p, executible)
41 if os.path.exists(path):
44 context.Result(result)
46 context.env[executible.upper()] = path
49 def _recursive_glob_dir(env, *args, **kwargs):
51 glob_results = env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs)
52 sds = list(subdirs(env, *(['*']+list(args[1:])), **kwargs))
53 return (sds, glob_results)
55 def recursive_glob(env, *args, **kwargs):
56 dir_stack = [kwargs.pop('cwd', None)]
58 while len(dir_stack) > 0:
59 kwargs['cwd'] = dir_stack.pop(0)
60 subdirs,results = _recursive_glob_dir(env, *args, **kwargs)
61 dir_stack.extend(subdirs)
62 glob_results.extend(results)
65 def link_wtk_graph(env):
66 return env.Command('wtk_graph.asy', '../asy/wtk_graph.asy',
67 SCons.Script.Copy('$TARGET', '$SOURCE'))
70 return env.Command('pyfit', '../script/pyfit',
71 SCons.Script.Copy('$TARGET', '$SOURCE'))