SCons supports the ability for a Builder to modify the lists of target(s) from the specified source(s).
def modify_targets(target, source, env):
target.append('new_target')
source.append('new_source')
return target, source
bld = Builder(action = 'foobuild $TARGETS - $SOURCES',
suffix = '.foo',
src_suffix = '.input',
emitter = modify_targets)
env = Environment(BUILDERS = {'Foo' : bld})
env.Foo('file')
% scons -Q
foobuild file.foo new_target - file.input new_source
bld = Builder(action = 'my_command',
suffix = '.foo',
src_suffix = '.input',
emitter = 'MY_EMITTER')
def modify1(target, source, env):
return target, source
def modify2(target, source, env):
return target, source
env1 = Environment(BUILDERS = {'Foo' : bld},
MY_EMITTER = modify1)
env2 = Environment(BUILDERS = {'Foo' : bld},
MY_EMITTER = modify2)
env1.Foo('file1')
env2.Foo('file2')