From eee3ebdb2cf3e025294d387316b2601feb2a8ce6 Mon Sep 17 00:00:00 2001 From: Aaron Boman Date: Sat, 8 Oct 2016 15:58:38 -0500 Subject: [PATCH] Allow for actions to be empty. This allows for an updating rule to not run an action itself, rather it allows for that rule to delegate to other updating actions. --- src/build/engine.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/build/engine.py b/src/build/engine.py index 9d6b99c50..c409276b6 100644 --- a/src/build/engine.py +++ b/src/build/engine.py @@ -16,21 +16,23 @@ from b2.util import set_jam_action, is_iterable class BjamAction(object): """Class representing bjam action defined from Python.""" - def __init__(self, action_name, function): + def __init__(self, action_name, function, has_command=False): assert isinstance(action_name, basestring) assert callable(function) or function is None self.action_name = action_name self.function = function + self.has_command = has_command def __call__(self, targets, sources, property_set_): assert is_iterable(targets) assert is_iterable(sources) assert isinstance(property_set_, property_set.PropertySet) - # Bjam actions defined from Python have only the command - # to execute, and no associated jam procedural code. So - # passing 'property_set' to it is not necessary. - bjam_interface.call("set-update-action", self.action_name, - targets, sources, []) + if self.has_command: + # Bjam actions defined from Python have only the command + # to execute, and no associated jam procedural code. So + # passing 'property_set' to it is not necessary. + bjam_interface.call("set-update-action", self.action_name, + targets, sources, []) if self.function: self.function(targets, sources, property_set_) @@ -158,7 +160,7 @@ class Engine: self.do_set_update_action (action_name, targets, sources, properties) - def register_action (self, action_name, command, bound_list = [], flags = [], + def register_action (self, action_name, command='', bound_list = [], flags = [], function = None): """Creates a new build engine action. @@ -190,7 +192,8 @@ class Engine: if command: bjam_interface.define_action(action_name, command, bound_list, bjam_flags) - self.actions[action_name] = BjamAction(action_name, function) + self.actions[action_name] = BjamAction( + action_name, function, has_command=bool(command)) def register_bjam_action (self, action_name, function=None): """Informs self that 'action_name' is declared in bjam.