Skip to content

Instantly share code, notes, and snippets.

@seanhoughton
Last active December 26, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanhoughton/7148635 to your computer and use it in GitHub Desktop.
Save seanhoughton/7148635 to your computer and use it in GitHub Desktop.
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…
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.
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