From 5a3a89b4de7e7fd7ee42bc725c41d05268073775 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 24 Dec 2015 18:28:20 +0100 Subject: [PATCH] Stop adding incompatible task data into the same dict objects --- TODO | 2 +- playground/dynamic_headers/wscript | 2 +- waflib/Build.py | 18 ++++++++++++------ waflib/Node.py | 2 +- waflib/Runner.py | 3 +-- waflib/Task.py | 14 +++++++------- waflib/Tools/javaw.py | 4 ++-- waflib/extras/doxygen.py | 2 +- 8 files changed, 26 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index 1c3d35f3..d889e766 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ Waf 1.9 ------- -* Reduce the key size in bld.task_sigs * Provide a more efficient ConfigSet implementation * Ensure _cache.py are valid python files * Rework qt5 @@ -25,4 +24,5 @@ Done * Remove Node.cache_sig and Node.sig #1580 * Remove __hash__ and __eq__ from Node and Task #1629 * Set cflags in the beginning / cppflags at the end #1505 +* Reduce the key size in bld.task_sigs by adding bld.node_sigs and bld.imp_sigs diff --git a/playground/dynamic_headers/wscript b/playground/dynamic_headers/wscript index 39fe189d..fa3646ec 100644 --- a/playground/dynamic_headers/wscript +++ b/playground/dynamic_headers/wscript @@ -73,7 +73,7 @@ def runnable_status(self): if add: # recompute the task signature delattr(self, 'cache_sig') - del bld.task_sigs[(self.uid(), 'imp')] + del bld.imp_sigs[self.uid()] return self.runnable_status() for x in bld.node_deps[self.uid()]: diff --git a/waflib/Build.py b/waflib/Build.py index 76054742..3f5bf427 100644 --- a/waflib/Build.py +++ b/waflib/Build.py @@ -29,8 +29,8 @@ INSTALL = 1337 UNINSTALL = -1337 """Negative value '<-' uninstall, see :py:attr:`waflib.Build.BuildContext.is_install`""" -SAVED_ATTRS = 'root node_deps raw_deps task_sigs'.split() -"""Build class members to save between the runs (root, node_deps, raw_deps, task_sigs)""" +SAVED_ATTRS = 'root node_sigs task_sigs imp_sigs raw_deps node_deps'.split() +"""Build class members to save between the runs (root, node_sigs, task_sigs, node_sigs, imp_sigs, raw_deps, node_deps)""" CFG_FILES = 'cfg_files' """Files from the build directory to hash before starting the build (``config.h`` written during the configuration)""" @@ -80,14 +80,20 @@ class BuildContext(Context.Context): # ======================================= # # cache variables + self.node_sigs = {} + """Dict mapping build nodes to task identifier (uid), it indicates whether a task created a particular file (persists between builds)""" + self.task_sigs = {} - """Signatures of the tasks (persists between build executions)""" + """Dict mapping task identifiers (uid) to task signatures (persists between builds)""" + + self.imp_sigs = {} + """Dict mapping task identifiers (uid) to implicit task dependencies used for scanning targets (persists between builds)""" self.node_deps = {} - """Dict of node dependencies found by :py:meth:`waflib.Task.Task.scan` (persists between build executions)""" + """Dict mapping task identifiers (uid) to node dependencies found by :py:meth:`waflib.Task.Task.scan` (persists between builds)""" self.raw_deps = {} - """Dict of custom data returned by :py:meth:`waflib.Task.Task.scan` (persists between build executions)""" + """Dict mapping task identifiers (uid) to custom data returned by :py:meth:`waflib.Task.Task.scan` (persists between builds)""" # list of folders that are already scanned # so that we do not need to stat them one more time @@ -1214,7 +1220,7 @@ class CleanContext(BuildContext): n.delete() self.root.children = {} - for v in 'node_deps task_sigs raw_deps'.split(): + for v in 'node_sigs task_sigs imp_sigs raw_deps node_deps'.split(): setattr(self, v, {}) class ListContext(BuildContext): diff --git a/waflib/Node.py b/waflib/Node.py index 01f0c118..6f945867 100644 --- a/waflib/Node.py +++ b/waflib/Node.py @@ -816,7 +816,7 @@ class Node(object): the signature calculation relies on an existing attribute. Else the signature is calculated automatically. """ - # previous behaviour can be set by returning self.ctx.task_sigs[self] when a build node + # previous behaviour can be set by returning self.ctx.node_sigs[self] when a build node return Utils.h_file(self.abspath()) # -------------------------------------------- diff --git a/waflib/Runner.py b/waflib/Runner.py index b3087292..7ff42a86 100644 --- a/waflib/Runner.py +++ b/waflib/Runner.py @@ -280,9 +280,8 @@ class Parallel(object): """ if hasattr(tsk, 'scan') and hasattr(tsk, 'uid'): # TODO waf 1.9 - this breaks encapsulation - key = (tsk.uid(), 'imp') try: - del self.bld.task_sigs[key] + del self.bld.imp_sigs[tsk.uid()] except KeyError: pass if not self.bld.keep: diff --git a/waflib/Task.py b/waflib/Task.py index e29b386a..6631e626 100644 --- a/waflib/Task.py +++ b/waflib/Task.py @@ -607,7 +607,7 @@ class Task(TaskBase): # compare the signatures of the outputs for node in self.outputs: - sig = bld.task_sigs.get(node, None) + sig = bld.node_sigs.get(node, None) if not sig: Logs.debug("task: task %r must run: an output node has no signature" % self) return RUN_ME @@ -628,14 +628,14 @@ class Task(TaskBase): The node signature is obtained from the task signature, but the output nodes may also get the signature of their contents. See the class decorator :py:func:`waflib.Task.update_outputs` if you need this behaviour. """ - dct = self.generator.bld.task_sigs + bld = self.generator.bld for node in self.outputs: if not node.exists(): self.hasrun = MISSING self.err_msg = '-> missing file: %r' % node.abspath() raise Errors.WafError(self.err_msg) - dct[node] = self.uid() # make sure this task produced the files in question - dct[self.uid()] = self.signature() + bld.node_sigs[node] = self.uid() # make sure this task produced the files in question + bld.task_sigs[self.uid()] = self.signature() def sig_explicit_deps(self): """ @@ -729,7 +729,7 @@ class Task(TaskBase): # get the task signatures from previous runs key = self.uid() - prev = bld.task_sigs.get((key, 'imp'), []) + prev = bld.imp_sigs.get(key, []) # for issue #379 if prev: @@ -751,7 +751,7 @@ class Task(TaskBase): del x.parent.children[x.name] except KeyError: pass - del bld.task_sigs[(key, 'imp')] + del bld.imp_sigs[key] raise Errors.TaskRescan('rescan') # no previous run or the signature of the dependencies has changed, rescan the dependencies @@ -768,7 +768,7 @@ class Task(TaskBase): # recompute the signature and return it try: - bld.task_sigs[(key, 'imp')] = sig = self.compute_sig_implicit_deps() + bld.imp_sigs[key] = sig = self.compute_sig_implicit_deps() except Exception: if Logs.verbose: for k in bld.node_deps.get(self.uid(), []): diff --git a/waflib/Tools/javaw.py b/waflib/Tools/javaw.py index 525e419c..831a6458 100644 --- a/waflib/Tools/javaw.py +++ b/waflib/Tools/javaw.py @@ -301,7 +301,7 @@ class javac(Task.Task): """ """ for node in self.generator.outdir.ant_glob('**/*.class'): - bld.task_sigs[node] = self.uid() + bld.node_sigs[node] = self.uid() self.generator.bld.task_sigs[self.uid()] = self.cache_sig @feature('javadoc') @@ -351,7 +351,7 @@ class javadoc(Task.Task): def post_run(self): nodes = self.generator.javadoc_output.ant_glob('**') for nodes in nodes: - bld.task_sigs[node] = self.uid() + bld.node_sigs[node] = self.uid() self.generator.bld.task_sigs[self.uid()] = self.cache_sig def configure(self): diff --git a/waflib/extras/doxygen.py b/waflib/extras/doxygen.py index d0c29285..b2b6e01c 100644 --- a/waflib/extras/doxygen.py +++ b/waflib/extras/doxygen.py @@ -148,7 +148,7 @@ class doxygen(Task.Task): def post_run(self): nodes = self.output_dir.ant_glob('**/*', quiet=True) for x in nodes: - self.generator.bld.task_sigs[x.abspath()] = self.uid() + self.generator.bld.node_sigs[x] = self.uid() self.add_install() return Task.Task.post_run(self)