mirror of https://gitlab.com/ita1024/waf.git
Smarter "reentrant" behaviour for TaskGen.declare_chain
Re-add to the list of source files the files that have an existing mapping.
This commit is contained in:
parent
1bf049e4fc
commit
476f89681a
|
@ -293,7 +293,7 @@ class task_gen(object):
|
||||||
|
|
||||||
return newobj
|
return newobj
|
||||||
|
|
||||||
def declare_chain(name='', rule=None, reentrant=True, color='BLUE',
|
def declare_chain(name='', rule=None, reentrant=None, color='BLUE',
|
||||||
ext_in=[], ext_out=[], before=[], after=[], decider=None, scan=None, install_path=None, shell=False):
|
ext_in=[], ext_out=[], before=[], after=[], decider=None, scan=None, install_path=None, shell=False):
|
||||||
"""
|
"""
|
||||||
Create a new mapping and a task class for processing files by extension.
|
Create a new mapping and a task class for processing files by extension.
|
||||||
|
@ -303,8 +303,8 @@ def declare_chain(name='', rule=None, reentrant=True, color='BLUE',
|
||||||
:type name: string
|
:type name: string
|
||||||
:param rule: function to execute or string to be compiled in a function
|
:param rule: function to execute or string to be compiled in a function
|
||||||
:type rule: string or function
|
:type rule: string or function
|
||||||
:param reentrant: re-inject the output file in the process
|
:param reentrant: re-inject the output file in the process (done automatically, set to 0 to disable)
|
||||||
:type reentrant: bool
|
:type reentrant: int
|
||||||
:param color: color for the task output
|
:param color: color for the task output
|
||||||
:type color: string
|
:type color: string
|
||||||
:param ext_in: execute the task only after the files of such extensions are created
|
:param ext_in: execute the task only after the files of such extensions are created
|
||||||
|
@ -332,13 +332,27 @@ def declare_chain(name='', rule=None, reentrant=True, color='BLUE',
|
||||||
ext = decider and decider(self, node) or cls.ext_out
|
ext = decider and decider(self, node) or cls.ext_out
|
||||||
if ext_in:
|
if ext_in:
|
||||||
_ext_in = ext_in[0]
|
_ext_in = ext_in[0]
|
||||||
out_source = [node.change_ext(x, ext_in=_ext_in) for x in ext]
|
|
||||||
if reentrant:
|
tsk = self.create_task(name, node)
|
||||||
for i in range(reentrant):
|
cnt = 0
|
||||||
self.source.append(out_source[i])
|
|
||||||
tsk = self.create_task(name, node, out_source)
|
keys = self.mappings.keys() + self.__class__.mappings.keys()
|
||||||
|
for x in ext:
|
||||||
|
k = node.change_ext(x, ext_in=_ext_in)
|
||||||
|
tsk.outputs.append(k)
|
||||||
|
|
||||||
|
if reentrant != None:
|
||||||
|
if cnt < int(reentrant):
|
||||||
|
self.source.append(k)
|
||||||
|
else:
|
||||||
|
for y in keys: # ~ nfile * nextensions :-/
|
||||||
|
if x.endswith(y):
|
||||||
|
self.source.append(k)
|
||||||
|
break
|
||||||
|
cnt += 1
|
||||||
|
|
||||||
if install_path:
|
if install_path:
|
||||||
self.bld.install_files(install_path, out_source)
|
self.bld.install_files(install_path, tsk.outputs)
|
||||||
return tsk
|
return tsk
|
||||||
|
|
||||||
for x in cls.ext_in:
|
for x in cls.ext_in:
|
||||||
|
|
|
@ -10,7 +10,6 @@ from waflib import TaskGen
|
||||||
|
|
||||||
TaskGen.declare_chain(name = 'erlc',
|
TaskGen.declare_chain(name = 'erlc',
|
||||||
rule = '${ERLC} ${ERLC_FLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}',
|
rule = '${ERLC} ${ERLC_FLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}',
|
||||||
reentrant = False,
|
|
||||||
ext_in = '.erl',
|
ext_in = '.erl',
|
||||||
ext_out = '.beam')
|
ext_out = '.beam')
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,5 @@ TaskGen.declare_chain(
|
||||||
rule = proc,
|
rule = proc,
|
||||||
ext_in = '.pc',
|
ext_in = '.pc',
|
||||||
ext_out = '.c',
|
ext_out = '.c',
|
||||||
reentrant = True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue