Fix specifying only the source argument to a MultiStepBuilder (such as Program).
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 7 Jan 2003 06:08:53 +0000 (06:08 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 7 Jan 2003 06:08:53 +0000 (06:08 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@537 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Builder.py
src/engine/SCons/BuilderTests.py
test/Program.py

index 0c608da5351f9fb1c2bc47c9d26c106bf851cf71..c297718430c1158f9c4afbefc48e8b46c1395ff0 100644 (file)
@@ -34,6 +34,9 @@ RELEASE 0.10 - XXX
   - Significant performance improvement from using a more efficient
     check, throughout the code, for whether a Node has a Builder.
 
+  - Fix specifying only the source file to MultiStepBuilders such as
+    the Program Builder.  (Bug reported by Dean Bair.)
+
   From Steve Leblanc:
 
   - Add a Clean() method to support removing user-specified targets
index 15358c1cc947de0eef88ef79280a6492204f5f3c..2c458556f1f394cd460afeddc54d29d957115db7 100644 (file)
@@ -425,7 +425,11 @@ class MultiStepBuilder(BuilderBase):
         self.sdict = {}
         self.cached_src_suffixes = {} # source suffixes keyed on id(env)
 
-    def __call__(self, env, target = None, source = None, **kw):
+    def __call__(self, env, target = None, source = _null, **kw):
+        if source is _null:
+            source = target
+            target = None
+
         slist = SCons.Node.arg2nodes(source, self.source_factory)
         final_sources = []
 
index 9905eb90607a6a253012d3b0a6521791022f5e49..57069dfc5ec3ab170bbe0cd4b5b38217aac83d41 100644 (file)
@@ -420,6 +420,12 @@ class BuilderTestCase(unittest.TestCase):
         assert str(tgt.sources[1]) == 'test2.foo', str(tgt.sources[1])
         assert str(tgt.sources[2]) == 'test3.txt', str(tgt.sources[2])
 
+        tgt = builder2(env, 'aaa.bar')
+        assert str(tgt) == 'aaa', str(tgt)
+        assert str(tgt.sources[0]) == 'aaa.foo', str(tgt.sources[0])
+        assert str(tgt.sources[0].sources[0]) == 'aaa.bar', \
+               str(tgt.sources[0].sources[0])
+
         builder3 = SCons.Builder.MultiStepBuilder(name = "builder3",
                                                   action = 'foo',
                                                   src_builder = 'xyzzy',
index 5e1f259d95edfd819eefc33b318b32fb1e1c4c9c..ee892998e2325860af9978d953187932497ff496 100644 (file)
@@ -39,13 +39,17 @@ test = TestSCons.TestSCons()
 foo1 = test.workpath('foo1' + _exe)
 foo2 = test.workpath('foo2' + _exe)
 foo3 = test.workpath('foo3' + _exe)
-foo_args = 'foo1%s foo2%s foo3%s' % (_exe, _exe, _exe)
+foo4 = test.workpath('foo4' + _exe)
+foo5 = test.workpath('foo5' + _exe)
+foo_args = 'foo1%s foo2%s foo3%s foo4%s foo5%s' % (_exe, _exe, _exe, _exe, _exe)
 
 test.write('SConstruct', """
 env = Environment()
 env.Program(target = 'foo1', source = 'f1.c')
 env.Program(target = 'foo2', source = Split('f2a.c f2b.c f2c.c'))
 env.Program(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
+env.Program('foo4', 'f4.c')
+env.Program('foo5.c')
 """)
 
 test.write('f1.c', r"""
@@ -118,11 +122,33 @@ main(int argc, char *argv[])
 }
 """)
 
+test.write('f4.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("f4.c\n");
+       exit (0);
+}
+""")
+
+test.write('foo5.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("foo5.c\n");
+       exit (0);
+}
+""")
+
 test.run(arguments = '.')
 
 test.run(program = foo1, stdout = "f1.c\n")
 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
 test.run(program = foo3, stdout = "f3a.c\nf3b.c\nf3c.c\n")
+test.run(program = foo4, stdout = "f4.c\n")
+test.run(program = foo5, stdout = "foo5.c\n")
 
 test.up_to_date(arguments = '.')
 
@@ -144,11 +170,33 @@ f3b(void)
 }
 """)
 
+test.write('f4.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("f4.c X\n");
+       exit (0);
+}
+""")
+
+test.write('foo5.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("foo5.c X\n");
+       exit (0);
+}
+""")
+
 test.run(arguments = '.')
 
 test.run(program = foo1, stdout = "f1.c X\n")
 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
 test.run(program = foo3, stdout = "f3a.c\nf3b.c X\nf3c.c\n")
+test.run(program = foo4, stdout = "f4.c X\n")
+test.run(program = foo5, stdout = "foo5.c X\n")
 
 test.up_to_date(arguments = '.')
 
@@ -156,6 +204,8 @@ test.up_to_date(arguments = '.')
 oldtime1 = os.path.getmtime(foo1)
 oldtime2 = os.path.getmtime(foo2)
 oldtime3 = os.path.getmtime(foo3)
+oldtime4 = os.path.getmtime(foo4)
+oldtime5 = os.path.getmtime(foo5)
 
 time.sleep(2) # introduce a small delay, to make the test valid
 
@@ -164,6 +214,8 @@ test.run(arguments = foo_args)
 test.fail_test(oldtime1 != os.path.getmtime(foo1))
 test.fail_test(oldtime2 != os.path.getmtime(foo2))
 test.fail_test(oldtime3 != os.path.getmtime(foo3))
+test.fail_test(oldtime4 != os.path.getmtime(foo4))
+test.fail_test(oldtime5 != os.path.getmtime(foo5))
 
 test.write('f1.c', r"""
 int
@@ -183,11 +235,33 @@ f3b(void)
 }
 """)
 
+test.write('f4.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("f4.c Y\n");
+       exit (0);
+}
+""")
+
+test.write('foo5.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("foo5.c Y\n");
+       exit (0);
+}
+""")
+
 test.run(arguments = foo_args)
 
 test.run(program = foo1, stdout = "f1.c Y\n")
 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
 test.run(program = foo3, stdout = "f3a.c\nf3b.c Y\nf3c.c\n")
+test.run(program = foo4, stdout = "f4.c Y\n")
+test.run(program = foo5, stdout = "foo5.c Y\n")
 
 test.up_to_date(arguments = foo_args)
 
@@ -209,11 +283,33 @@ f3b(void)
 }
 """)
 
+test.write('f4.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("f4.c Z\n");
+       exit (0);
+}
+""")
+
+test.write('foo5.c', r"""
+int
+main(int argc, char *argv[])
+{
+       argv[argc++] = "--";
+       printf("foo5.c Z\n");
+       exit (0);
+}
+""")
+
 test.run(arguments = foo_args)
 
 test.run(program = foo1, stdout = "f1.c Z\n")
 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
 test.run(program = foo3, stdout = "f3a.c\nf3b.c Z\nf3c.c\n")
+test.run(program = foo4, stdout = "f4.c Z\n")
+test.run(program = foo5, stdout = "foo5.c Z\n")
 
 test.up_to_date(arguments = foo_args)
 
@@ -221,6 +317,8 @@ test.up_to_date(arguments = foo_args)
 oldtime1 = os.path.getmtime(foo1)
 oldtime2 = os.path.getmtime(foo2)
 oldtime3 = os.path.getmtime(foo3)
+oldtime4 = os.path.getmtime(foo4)
+oldtime5 = os.path.getmtime(foo5)
 
 time.sleep(2) # introduce a small delay, to make the test valid
 
@@ -229,5 +327,7 @@ test.run(arguments = foo_args)
 test.fail_test(not (oldtime1 == os.path.getmtime(foo1)))
 test.fail_test(not (oldtime2 == os.path.getmtime(foo2)))
 test.fail_test(not (oldtime3 == os.path.getmtime(foo3)))
+test.fail_test(not (oldtime4 == os.path.getmtime(foo4)))
+test.fail_test(not (oldtime5 == os.path.getmtime(foo5)))
 
 test.pass_test()