scons icon indicating copy to clipboard operation
scons copied to clipboard

Multiple actions with batch_key=True passed into a env.Command run non-batched

Open zamn opened this issue 5 years ago • 1 comments

Describe the bug When I have multiple env.Action(action_func, batch_key=True) statements inside of a

env.Command(target=t, source=s, action=[env.Action(action_func, batch_key=True), env.Action(action_func, batch_key=True)])

the Command will run them as if they were never batched (i.e. batch_key=False).

Required information

  • Link to SCons Users thread discussing your issue. Discussed in discord

  • Version of SCons 3.1.2

  • Version of Python 2.7.16

  • Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc) pip

  • How you installed SCons pip install scons --user

  • What Platform are you on? (Linux/Windows and which version) Mac OS

  • How to reproduce your issue? Please include a small self contained reproducer. Likely a SConstruct should do for most issues.

import os

env = Environment(ENV=os.environ)

def action_func(target = None, source = None, env = None):
    print('my targets', target)
    return 0

my_batched_action = env.Action(action_func, batch_key=True)

env.Command(target='hello', source='world', action=my_batched_action)
env.Command(target='goodbye', source='world', action=my_batched_action)

# The above output:
# action_func(["hello", "goodbye"], ["world", "world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8737250>, <SCons.Node.FS.File object at 0x55e4f87379f0>])

my_second_batched_action = env.Action(action_func, batch_key=True)

env.Command(target='end', source='world', action=[my_batched_action, my_second_batched_action])
env.Command(target='sad', source='world', action=[my_batched_action, my_second_batched_action])

# action_func(["end"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8738cb0>])
# action_func(["end"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8738cb0>])
# action_func(["sad"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8739250>])
# action_func(["sad"], ["world"])
# ('my targets', [<SCons.Node.FS.File object at 0x55e4f8739250>])

# I would expect it to match the first example.
  • How you invoke scons (The command line you're using "scons --flags some_arguments") scons

zamn avatar Mar 03 '20 21:03 zamn

My alteration to the reproducer and a patch:

90f7fbc253c9363648191227850059b6-f1bf47c613a7988942294926131a1327a6f25249.zip

It looks like minimally ListAction() doesn't propagate the batch_key for the Action(s). (The included patch resolves this, though it may not be the ideal way to fix)

Also when this is used in a Command it doesn't but the code path is different.

bdbaddog avatar Mar 03 '20 21:03 bdbaddog