2 import SCons.Action, SCons.Builder, SCons.Node.FS
4 def installDirFilter(target, source, env):
5 install = env['INSTALL']
6 suffixes = env.get('FILTER_SUFFIXES',[])
8 for t,s in zip(target,source):
9 for path, dirs, files in os.walk(s.get_path()):
11 tdir = t.Dir(sdir.get_path(s))
12 if not os.path.exists(tdir.get_path()):
13 os.makedirs(tdir.get_path())
16 if suffixes and sfile.suffix not in suffixes : continue
17 tfile = tdir.File(sfile.name)
18 if install(tfile.get_path(), sfile.get_path(), env):
22 def installDirFilterStr(target, source, env):
23 suffixes = env.get('FILTER_SUFFIXES')
24 if suffixes : suffixes = " (only %s)" % " ".join(suffixes)
25 return 'Install directory: "%s" as "%s"%s' % (str(source[0]), str(target[0]), suffixes)
27 InstallDirAction = SCons.Action.Action(installDirFilter, installDirFilterStr)
29 InstallDirBuilder = SCons.Builder.Builder(
30 action = InstallDirAction,
31 target_factory = SCons.Node.FS.Dir,
32 source_factory = SCons.Node.FS.Dir,
33 emitter = [ SCons.Tool.install.add_targets_to_INSTALLED_FILES, ])
35 def InstallDirWrapper(env, target=None, source=None, **kw):
36 target = env.arg2nodes(target, env.fs.Dir)
37 source = env.arg2nodes(source, env.fs.Dir)
41 builds.extend(InstallDirBuilder(env, t.Dir(s.name), s, **kw))
45 env['BUILDERS']['InstallDir'] = InstallDirWrapper