Commits

Anonymous committed 50c6c05

Make AlwaysBuild() work with Aliases.

Comments (0)

Files changed (4)

     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

src/engine/SCons/Node/NodeTests.py

     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):
         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
         """
     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
     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
     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

src/engine/SCons/Node/__init__.py

         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()

test/AlwaysBuild.py

 
 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')
       ))
 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()