From 4d1ed2099ab3b2df716bfcde8a152c6fc679f982 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 11 Nov 2004 13:55:32 +0000 Subject: [PATCH] Faster/leaner tree dumping. (Kevin Quick) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1156 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 2 + src/engine/SCons/Script/__init__.py | 4 +- src/engine/SCons/Util.py | 46 +++++++++++++++++++++-- src/engine/SCons/UtilTests.py | 58 ++++++++++++++++++++++++----- 4 files changed, 96 insertions(+), 14 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4c23967e..1bd5e014 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -273,6 +273,8 @@ RELEASE 0.97 - XXX - Handle Python stack traces consistently (stop at the SConscript stack frame, by default) even if the Python source code isn't available. + - Improve the performance of the --debug={tree,dtree} options. + From Levi Stephen: - Allow $JARCHDIR to be expanded to other construction variables. diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 712b4bab..a3d933d7 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -125,10 +125,10 @@ class BuildTask(SCons.Taskmaster.Task): # this method is serialized, but execute isn't: if print_tree and self.top: print - print SCons.Util.render_tree(self.targets[0], get_all_children) + SCons.Util.print_tree(self.targets[0], get_all_children) if print_dtree and self.top: print - print SCons.Util.render_tree(self.targets[0], get_derived_children) + SCons.Util.print_tree(self.targets[0], get_derived_children) if print_includes and self.top: t = self.targets[0] tree = t.render_include_tree() diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index b2bae65e..ec809b9f 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1018,7 +1018,9 @@ def render_tree(root, child_func, prune=0, margin=[0], visited={}): or in the whole tree if prune. """ - if visited.has_key(root): + rname = str(root) + + if visited.has_key(rname): return "" children = child_func(root) @@ -1029,10 +1031,10 @@ def render_tree(root, child_func, prune=0, margin=[0], visited={}): else: retval = retval + " " - retval = retval + "+-" + str(root) + "\n" + retval = retval + "+-" + rname + "\n" if not prune: visited = copy.copy(visited) - visited[root] = 1 + visited[rname] = 1 for i in range(len(children)): margin.append(i