Make AlwaysBuild() work with Aliases.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 Dec 2004 02:15:25 +0000 (02:15 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 17 Dec 2004 02:15:25 +0000 (02:15 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1193 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/__init__.py
test/AlwaysBuild.py

index c59f61f61943b9dae75d3b1fc2ed00856a54c28e..e97ea15e269711abde2637dcac4092e05588a139 100644 (file)
@@ -159,6 +159,10 @@ RELEASE 0.97 - XXX
     matter whether the dependency file is in a Repository or not.
     This may cause recompilations upon upgrade to this version.
 
+  - Make AlwaysBuild() work with Alias and Python value Nodes (making
+    it much simpler to support aliases like "clean" that just invoke
+    an arbitrary action).
+
   From Wayne Lee:
 
   - Avoid "maximum recursion limit" errors when removing $(-$) pairs
index 335c1a504bb4e8afed0b5cea3a43ddebd65b48b7..3c402d03fbd35eeaee964c426336e0d5ecb38e51 100644 (file)
@@ -186,6 +186,18 @@ class MyNode(SCons.Node.Node):
     def get_found_includes(self, env, scanner, target):
         return scanner(self)
 
+class Calculator:
+    def __init__(self, val):
+        self.max_drift = 0
+        class M:
+            def __init__(self, val):
+                self.val = val
+            def signature(self, args):
+                return self.val
+            def collect(self, args):
+                return reduce(lambda x, y: x+y, args, self.val)
+        self.module = M(val)
+
 
 
 class NodeTestCase(unittest.TestCase):
@@ -445,6 +457,23 @@ class NodeTestCase(unittest.TestCase):
         node = SCons.Node.Node()
         assert node.current() is None
 
+    def test_children_are_up_to_date(self):
+        """Test the children_are_up_to_date() method used by subclasses
+        """
+        n1 = SCons.Node.Node()
+        n2 = SCons.Node.Node()
+
+        calc = Calculator(111)
+
+        n1.add_source(n2)
+        assert n1.children_are_up_to_date(calc), "expected up to date"
+        n2.set_state(SCons.Node.executed)
+        assert not n1.children_are_up_to_date(calc), "expected not up to date"
+        n2.set_state(SCons.Node.up_to_date)
+        assert n1.children_are_up_to_date(calc), "expected up to date"
+        n1.always_build = 1
+        assert not n1.children_are_up_to_date(calc), "expected not up to date"
+
     def test_env_set(self):
         """Test setting a Node's Environment
         """
@@ -464,15 +493,6 @@ class NodeTestCase(unittest.TestCase):
     def test_calc_bsig(self):
         """Test generic build signature calculation
         """
-        class Calculator:
-            def __init__(self, val):
-                self.max_drift = 0
-                class M:
-                    def __init__(self, val):
-                        self.val = val
-                    def collect(self, args):
-                        return reduce(lambda x, y: x+y, args, self.val)
-                self.module = M(val)
         node = SCons.Node.Node()
         result = node.calc_bsig(Calculator(222))
         assert result == 222, result
@@ -482,15 +502,6 @@ class NodeTestCase(unittest.TestCase):
     def test_calc_csig(self):
         """Test generic content signature calculation
         """
-        class Calculator:
-            def __init__(self, val):
-                self.max_drift = 0
-                class M:
-                    def __init__(self, val):
-                        self.val = val
-                    def signature(self, args):
-                        return self.val
-                self.module = M(val)
         node = SCons.Node.Node()
         result = node.calc_csig(Calculator(444))
         assert result == 444, result
@@ -500,16 +511,6 @@ class NodeTestCase(unittest.TestCase):
     def test_gen_binfo(self):
         """Test generating a build information structure
         """
-        class Calculator:
-            def __init__(self, val):
-                self.max_drift = 0
-                class M:
-                    def __init__(self, val):
-                        self.val = val
-                    def collect(self, args):
-                        return reduce(lambda x, y: x+y, args, self.val)
-                self.module = M(val)
-
         node = SCons.Node.Node()
         binfo = node.gen_binfo(Calculator(666))
         assert isinstance(binfo, SCons.Node.BuildInfo), binfo
index f0e750b8c9e8a3d2c8345fbab2c10b11a488525f..c7a652de8d195a2cf9311443a8ddbdea209ad19b 100644 (file)
@@ -839,6 +839,8 @@ class Node:
         rebind their current() method to this method."""
         # Allow the children to calculate their signatures.
         self.binfo = self.gen_binfo(calc)
+        if self.always_build:
+            return None
         state = 0
         for kid in self.children(None):
             s = kid.get_state()
index 2c508410fc03700952c135d58dbc99d3676507dd..a10730237ffc12fa6c2d5d6510fb5ad1e4dc3bde 100644 (file)
@@ -45,6 +45,11 @@ AlwaysBuild('f1.out')
 
 env.B(r'%s', source='f3.in')
 env.AlwaysBuild(r'%s')
+
+env.Alias('clean1', [], Delete('clean1-target'))
+env.AlwaysBuild('clean1')
+c2 = env.Alias('clean2', [], [Delete('clean2-t1'), Delete('clean2-t2')])
+env.AlwaysBuild(c2)
 """ % (os.path.join('sub', 'f3.out'),
        os.path.join('$SUBDIR', 'f3.out')
       ))
@@ -63,4 +68,13 @@ test.run(arguments = ".")
 test.fail_test(test.read('f1.out') != '2')
 test.fail_test(test.read(['sub', 'f3.out']) != '2')
 
+test.run(arguments = 'clean1', stdout=test.wrap_stdout("""\
+Delete("clean1-target")
+"""))
+
+test.run(arguments = 'clean2', stdout=test.wrap_stdout("""\
+Delete("clean2-t1")
+Delete("clean2-t2")
+"""))
+
 test.pass_test()