import os.path
import SCons.Node.FS
+
+def subdirs(env, *args, **kwargs):
+ for subdir in env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs):
+ if isinstance(subdir, SCons.Node.FS.Dir):
+ yield subdir
+
def include_child_SConscripts(env, SConscript):
"""Get all the nested SConscripts in that may alter and pass back
the environment. They may also add thesis subdependencies to that
environment.
"""
- for subdir in env.Glob('*'):
- if not isinstance(subdir, SCons.Node.FS.Dir):
- continue # subdir isn't a directory
+ for subdir in subdirs(env, '*'):
var_sconscript_path = os.path.join(subdir.abspath,
'SConscript')
src_sconscript_path = os.path.join(subdir.srcnode().abspath,
return result
def _recursive_glob_dir(env, *args, **kwargs):
+ assert len(args) > 0
glob_results = env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs)
- assert 'pattern' not in kwargs, kwargs # or we'd need subdir_kwargs
- subdirs = []
- for subdir in env.fs.Glob(env.subst('*'), *args[1:], **kwargs):
- if not isinstance(subdir, SCons.Node.FS.Dir):
- continue # subdir isn't a directory
- subdirs.append(subdir)
- return (subdirs, glob_results)
+ sds = list(subdirs(env, ['*']+args[1:], **kwargs))
+ return (sds, glob_results)
def recursive_glob(env, *args, **kwargs):
dir_stack = [kwargs.pop('cwd', None)]