Builders That Modify the Target or Source Lists Using an Emitter

SCons User Guide 0.98.0
Prev | Chapter 17. Writing Your Own Builders | Next

# 17.6. Builders That Modify the Target or Source Lists Using an `Emitter`

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')

Prev | Home | Next
Builders That Create Actions Using a `Generator` | Up | Not Writing a Builder: the `Command` Builder