Index: build/engine.py =================================================================== --- build/engine.py (revision 75605) +++ build/engine.py (working copy) @@ -15,9 +15,10 @@ class BjamAction: """Class representing bjam action defined from Python.""" - def __init__(self, action_name, function): + def __init__(self, action_name, function, chain_function): self.action_name = action_name self.function = function + self.chain_function = chain_function def __call__(self, targets, sources, property_set): if self.function: @@ -29,6 +30,11 @@ bjam_interface.call("set-update-action", self.action_name, targets, sources, []) + # Chain function allows invoking additional actions after + # the main update action. + if self.chain_function: + self.chain_function(targets, sources, property_set) + class BjamNativeAction: """Class representing bjam action defined by Jam code. @@ -109,7 +115,7 @@ self.do_set_update_action (action_name, targets, sources, properties) def register_action (self, action_name, command, bound_list = [], flags = [], - function = None): + function = None, chain_function = None): """Creates a new build engine action. Creates on bjam side an action named 'action_name', with @@ -132,10 +138,14 @@ bjam_flags = reduce(operator.or_, (action_modifiers[flag] for flag in flags), 0) - bjam_interface.define_action(action_name, command, bound_list, bjam_flags) + # We allow command to be empty so that we can define 'action' as pure + # python function that would do some conditional logic and then relay + # to other actions. + assert command or function + if command: + bjam_interface.define_action(action_name, command, bound_list, bjam_flags) + self.actions[action_name] = BjamAction(action_name, function, chain_function) - self.actions[action_name] = BjamAction(action_name, function) - def register_bjam_action (self, action_name, function=None): """Informs self that 'action_name' is declared in bjam.