mirror of https://gitlab.com/ita1024/waf.git
added Build.func to allow creating task generator using the decorator notation
Signed-off-by: Thomas Nagy <tnagy2pow10@gmail.com>
This commit is contained in:
parent
7895f84852
commit
c5bc3197f0
|
@ -152,6 +152,32 @@ class BuildContext(Context.Context):
|
|||
self.task_gen_cache_names = {} # reset the cache, each time
|
||||
self.add_to_group(ret, group=kw.get('group', None))
|
||||
return ret
|
||||
|
||||
def func(self, *k, **kw):
|
||||
"""
|
||||
Wrapper for creating a task generator using the decorator notation.
|
||||
|
||||
|
||||
The the following code:
|
||||
|
||||
@bld.func(
|
||||
target = "foo"
|
||||
)
|
||||
def _(tsk):
|
||||
print "bar"
|
||||
|
||||
is equivalent to:
|
||||
|
||||
def bar(tsk):
|
||||
print "bar"
|
||||
|
||||
bld(
|
||||
target = "foo",
|
||||
rule = bar,
|
||||
)
|
||||
"""
|
||||
return lambda rule: self (*k, rule=rule, **kw)
|
||||
|
||||
|
||||
def __copy__(self):
|
||||
"""Implemented to prevents copies of build contexts (raises an exception)"""
|
||||
|
|
Loading…
Reference in New Issue