ReplacingBuilder

class sconstool.util.ReplacingBuilder(wrapped, replacements={}, **kw)[source]

SCons builder wrapper, calls the wrapped builder with replaced construction variables.

Example:Typical usage

The following builder named MyObject is similar to SCons Object builder, but it uses MY_CFLAGS instead of CFLAGS.

from sconstool.util import ReplacingBuilder
from SCons.Environment import Environment

env = Environment(tools=['default'], MY_CFLAGS=['-Wall', '-Wextra'])
bld = ReplacingBuilder(env['BUILDERS']['Object'], CFLAGS='MY_CFLAGS')
env['BUILDERS']['MyObject'] = bld
bld.inject_replacements(env, 'SetDefault')

env.MyObject('test1.c') # gcc -c -o test1.o -Wall -Wextra test1.c
env.Object('test2.c')   # gcc -c -o test2.o test2.c
Parameters:
__call__(env, target, source, *args, **kw)[source]

Calls the wrapped builder with replaced construction variables.