Reputation: 658
I'm using scons 2.5.1. I want to create a builder with an emitter that changes the target name, e.g.:
def modify_targets(target, source, env):
target[0] = 'new_target'
return target, source
bld = Builder(action = 'echo $TARGETS - $SOURCES',
suffix = ".out",
src_suffix = '.input',
emitter = modify_targets)
env = Environment(BUILDERS = {'Foo' : bld})
env.Foo('file')
The dependency tree then looks like this:
$ scons -Q --tree=all,status
echo new_target - file.input
new_target - file.input
E = exists
R = exists in repository only
b = implicit builder
B = explicit builder
S = side effect
P = precious
A = always build
C = current
N = no clean
H = no cache
[E b ]+-.
[E C ] +-SConstruct
[E C ] +-file.input
[ ] +-file.out
[ B ] +-new_target
[E C ] +-file.input
[E C ] +-/bin/echo
There is this implicit file.out
which should be removed by the emitter. This is causing problems in a case when I need to create a dependency on a directory (e.g. the directory is a source). Scons then complains about Implicit dependency 'somedir/file.out' not found, needed by target 'xyz'
. This file will never exist. How can I force the Builder not to create the implicit dependency?
Update: it seems that the Builder first creates a SCons.Node.FS.Entry
which then remains somewhere in the cache even if it is removed from targets list by the emitter.
Upvotes: 0
Views: 814
Reputation: 4052
Edit:
I checked the sources, and what you're trying to achieve isn't possible via an Emitter. The specified targets and sources of a Builder will always be converted to SCons Nodes first internally. This is where the mysterious file.out
(or file
) comes from.
Only after this step, the Emitter gets called and gives you the opportunity to extend the list of emitted Nodes.
The only way I currently see is, to specify the final target name (new_file
) directly as target
in your Builder call. In your Emitter you could then add more target nodes if needed, but the first target will always be an implicit dependency, sorry.
For reference, what follows is my old, and wrong, answer:
Remove the
suffix = ".out",
line from the definition of your Builder. It enforces that the output file has to end with a .out
suffix, which is obviously not what you want in this case.
Upvotes: 0