mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 00:52:16 +00:00
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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user