From 06bdd82b434eb154e4dc45ac36d46ec6b9b27320 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 11 Dec 2001 04:52:18 +0000 Subject: [PATCH] Delay scanning a node from when we ask for its children to just before we're going to descend to its dependencies. git-svn-id: http://scons.tigris.org/svn/scons/trunk@139 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Node/__init__.py | 2 -- src/engine/SCons/Taskmaster.py | 2 ++ src/engine/SCons/TaskmasterTests.py | 27 +++++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 8b1ef55a..d444c3de 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -151,8 +151,6 @@ class Node: if parent not in self.parents: self.parents.append(parent) def children(self): - if not self.scanned: - self.scan() return self.sources + self.depends def get_parents(self): diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 1fb200c9..828fecd5 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -143,6 +143,8 @@ class Taskmaster: def __init__(self, targets=[], tasker=Task, calc=Calc()): def out_of_date(node): + # Scan the file before fetching its children(). + node.scan() return filter(lambda x: x.get_state() != SCons.Node.up_to_date, node.children()) diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index ca3037dd..5e661ee3 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -34,9 +34,10 @@ built = None executed = None class Node: - def __init__(self, name, kids = []): + def __init__(self, name, kids = [], scans = []): self.name = name self.kids = kids + self.scans = scans self.builder = Node.build self.bsig = None self.csig = None @@ -52,6 +53,12 @@ class Node: def children(self): return self.kids + + def scan(self): + self.kids = self.kids + self.scans + for scan in self.scans: + scan.parents.append(self) + self.scans = [] def get_parents(self): return self.parents @@ -210,7 +217,23 @@ class TaskmasterTestCase(unittest.TestCase): t.executed() assert not tm.is_blocked() t = tm.next_task() - assert tm. next_task() == None + assert tm.next_task() == None + + + n1 = Node("n1") + n2 = Node("n2") + n3 = Node("n3", [n1], [n2]) + tm = SCons.Taskmaster.Taskmaster([n3]) + t = tm.next_task() + assert t.get_target() == n1 + t.executed() + t = tm.next_task() + assert t.get_target() == n2 + t.executed() + t = tm.next_task() + assert t.get_target() == n3 + t.executed() + assert tm.next_task() == None def test_cycle_detection(self): n1 = Node("n1") -- 2.26.2