From 476f89681aa8bcbf83fa4b8db64b8bfbbaaecae7 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Tue, 4 Oct 2011 20:26:22 +0200 Subject: [PATCH] Smarter "reentrant" behaviour for TaskGen.declare_chain Re-add to the list of source files the files that have an existing mapping. --- waflib/TaskGen.py | 32 +++++++++++++++++++++++--------- waflib/extras/erlang.py | 1 - waflib/extras/proc.py | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/waflib/TaskGen.py b/waflib/TaskGen.py index 571b78d1..10ed1d31 100644 --- a/waflib/TaskGen.py +++ b/waflib/TaskGen.py @@ -293,7 +293,7 @@ class task_gen(object): 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): """ 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 :param rule: function to execute or string to be compiled in a function :type rule: string or function - :param reentrant: re-inject the output file in the process - :type reentrant: bool + :param reentrant: re-inject the output file in the process (done automatically, set to 0 to disable) + :type reentrant: int :param color: color for the task output :type color: string :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 if ext_in: _ext_in = ext_in[0] - out_source = [node.change_ext(x, ext_in=_ext_in) for x in ext] - if reentrant: - for i in range(reentrant): - self.source.append(out_source[i]) - tsk = self.create_task(name, node, out_source) + + tsk = self.create_task(name, node) + cnt = 0 + + 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: - self.bld.install_files(install_path, out_source) + self.bld.install_files(install_path, tsk.outputs) return tsk for x in cls.ext_in: diff --git a/waflib/extras/erlang.py b/waflib/extras/erlang.py index 4539ea9f..b6349fe0 100644 --- a/waflib/extras/erlang.py +++ b/waflib/extras/erlang.py @@ -10,7 +10,6 @@ from waflib import TaskGen TaskGen.declare_chain(name = 'erlc', rule = '${ERLC} ${ERLC_FLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}', - reentrant = False, ext_in = '.erl', ext_out = '.beam') diff --git a/waflib/extras/proc.py b/waflib/extras/proc.py index 417790df..f97adefb 100644 --- a/waflib/extras/proc.py +++ b/waflib/extras/proc.py @@ -52,6 +52,5 @@ TaskGen.declare_chain( rule = proc, ext_in = '.pc', ext_out = '.c', - reentrant = True, )