-
-
Save bdbaddog/90f7fbc253c9363648191227850059b6 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py | |
index 8a8cf2776..55120a884 100644 | |
--- a/src/engine/SCons/Action.py | |
+++ b/src/engine/SCons/Action.py | |
@@ -502,7 +502,7 @@ def _do_create_list_action(act, kw): | |
elif len(acts) == 1: | |
return acts[0] | |
else: | |
- return ListAction(acts) | |
+ return ListAction(acts, kw) | |
def Action(act, *args, **kw): | |
@@ -1326,7 +1326,7 @@ class FunctionAction(_ActionAction): | |
class ListAction(ActionBase): | |
"""Class for lists of other actions.""" | |
- def __init__(self, actionlist): | |
+ def __init__(self, actionlist, batch_key=None, **kw): | |
if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.ListAction') | |
def list_of_actions(x): | |
if isinstance(x, ActionBase): | |
@@ -1338,6 +1338,19 @@ class ListAction(ActionBase): | |
self.varlist = () | |
self.targets = '$TARGETS' | |
+ | |
+ if batch_key: | |
+ if not callable(batch_key): | |
+ # They have set batch_key, but not to their own | |
+ # callable. The default behavior here will batch | |
+ # *all* targets+sources using this action, separated | |
+ # for each construction environment. | |
+ def default_batch_key(self, env, target, source): | |
+ return (id(self), id(env)) | |
+ batch_key = default_batch_key | |
+ SCons.Util.AddMethod(self, batch_key, 'batch_key') | |
+ | |
+ | |
def genstring(self, target, source, env): | |
return '\n'.join([a.genstring(target, source, env) for a in self.list]) | |
This file contains 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
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, action_func], batch_key=True) | |
env.Command(target='end', source='world', action=my_second_batched_action) | |
env.Command(target='sad', source='world', 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment