Last active
December 26, 2015 12:09
SCons script that demonstrates the problem with batch building. After creating two dummy file they are correctly built together in one batch. If another build is initiated scons properly detects that no inputs have changed and doesn't build anything (but note that the output is missing mention of two.txt). The bug happens when you change only on…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
z:\repro> echo Hello > one.txt | |
z:\repro> echo Hello > two.txt | |
z:\repro> scons | |
scons: Reading SConscript files ... | |
scons: done reading SConscript files. | |
scons: Building targets ... | |
build_batch(["one.built", "two.built"], ["one.txt", "two.txt"]) | |
There are 2 targets | |
echo Hello from one.txt > one.built | |
echo Hello from two.txt > two.built | |
scons: done building targets. | |
z:\repro> scons | |
scons: Reading SConscript files ... | |
scons: done reading SConscript files. | |
scons: Building targets ... | |
scons: `one.built' is up to date. | |
scons: done building targets. | |
z:\repro> echo Changed > one.txt | |
scons: Reading SConscript files ... | |
scons: done reading SConscript files. | |
scons: Building targets ... | |
build_batch(["one.built", "two.built"], ["one.txt", "two.txt"]) | |
There are 2 targets | |
echo Hello from one.txt > one.built | |
echo Hello from two.txt > two.built | |
scons: done building targets. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env = Environment() | |
single_builder = Builder(action='echo Hello from $SOURCE > $TARGET', batch_key=True) | |
def build_batch(target, source, env): | |
print "There are %d targets" % len(target) | |
for s in zip(source, target): | |
env.Execute(env.subst('echo Hello from $SOURCE > $TARGET', source=s[0], target=s[1])) | |
batched_builder = Builder(action=Action(build_batch, batch_key=True, targets='$CHANGED_TARGETS')) | |
env.Append(BUILDERS={'Batched': batched_builder}) | |
inputs = ['one', 'two'] | |
Default([env.Batched(source=r'%s.txt' % name, target='%s.built' % name) for name in inputs]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment