Handle LIBPATH as a string (Crain).
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 23 Jan 2002 22:33:07 +0000 (22:33 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 23 Jan 2002 22:33:07 +0000 (22:33 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@218 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Scanner/Prog.py
src/engine/SCons/Scanner/ProgTests.py
test/LIBPATH.py

index 44946a0d2f8f63fee89ffcf336fb3ef56607174c..ea9bf431f7bec62b748e18d931aa51075f541dff 100644 (file)
@@ -15,6 +15,10 @@ RELEASE 0.04 -
   - Significant performance improvements in the Node.FS and
     Scanner subsystems.
 
+  - Fix signatures of binary files on Win32 systems.
+
+  - Allow LIBS and LIBPATH to be strings, not just arrays.
+
   From Steven Knight:
 
   - Fix using a directory as a Default(), and allow Default() to
index 0182cdaca4b6349667c6bc34f694cfe0a761b24e..2ca28f2ebed68a6ae398761d2fc32224c55d3df2 100644 (file)
@@ -26,6 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import SCons.Scanner
 import SCons.Node.FS
 import SCons.Util
+import string
 
 def ProgScan():
     """Return a prototype Scanner instance for scanning executable
@@ -42,13 +43,15 @@ def scan(node, env, node_factory):
 
     fs = SCons.Node.FS.default_fs
     try:
-        paths = map(lambda x, dir=fs.Dir: dir(x),
-                    env.Dictionary("LIBPATH"))
+        paths = SCons.Util.scons_str2nodes(env.Dictionary("LIBPATH"),
+                                           fs.Dir)
     except KeyError:
         paths = []
 
     try:
         libs = env.Dictionary("LIBS")
+        if SCons.Util.is_String(libs):
+            libs = string.split(libs)
     except KeyError:
         libs = []
 
index 6c3f5e4dcc350ef3d6c9604f4dd1e1aa04c1a8a8..e3765570c4de2cc73f186a935aa04f434ae934bf 100644 (file)
@@ -80,10 +80,20 @@ class ProgScanTestCase2(unittest.TestCase):
         deps = s.scan('dummy', env)
         assert deps_match(deps, ['l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib' ]), map(str, deps)
 
+class ProgScanTestCase3(unittest.TestCase):
+    def runTest(self):
+        env = DummyEnvironment(LIBPATH=test.workpath("d1/d2") + ' ' +\
+                               test.workpath("d1"),
+                               LIBS='l2 l3')
+        s = SCons.Scanner.Prog.ProgScan()
+        deps = s.scan('dummy', env)
+        assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps)
+
 def suite():
     suite = unittest.TestSuite()
     suite.addTest(ProgScanTestCase1())
     suite.addTest(ProgScanTestCase2())
+    suite.addTest(ProgScanTestCase3())
     return suite
 
 if __name__ == "__main__":
index a3734256cc97f13cc1559edddff221f0b287caad..68e83e19e62c51705d447607e53506a515b5126e 100644 (file)
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import TestSCons
+import sys
+import os.path
+import time
 
+if sys.platform == 'win32':
+    _exe = '.exe'
+else:
+    _exe = ''
+    
 test = TestSCons.TestSCons()
 
+prog1 = test.workpath('prog') + _exe
+prog2 = test.workpath('prog2') + _exe
+
 test.write('SConstruct', """
 env = Environment(LIBS = [ 'foo1' ],
                   LIBPATH = [ './libs' ])
 env.Program(target = 'prog', source = 'prog.c')
 env.Library(target = './libs/foo1', source = 'f1.c')
+
+env2 = Environment(LIBS = 'foo2',
+                   LIBPATH = '.')
+env2.Program(target = 'prog2', source = 'prog.c')
+env2.Library(target = 'foo2', source = 'f1.c')
 """)
 
 test.write('f1.c', r"""
@@ -57,8 +73,32 @@ main(int argc, char *argv[])
 
 test.run(arguments = '.')
 
-test.run(program = test.workpath('prog'),
+test.run(program = prog1,
          stdout = "f1.c\nprog.c\n")
+test.run(program = prog2,
+         stdout = "f1.c\nprog.c\n")
+
+oldtime1 = os.path.getmtime(prog1)
+oldtime2 = os.path.getmtime(prog2)
+time.sleep(2)
+test.run(arguments = '.')
+
+test.fail_test(oldtime1 != os.path.getmtime(prog1))
+test.fail_test(oldtime2 != os.path.getmtime(prog2))
+
+test.write('f1.c', r"""
+void
+f1(void)
+{
+       printf("f1.cnew\n");
+}
+""")
+
+test.run(arguments = '.')
+test.run(program = prog1,
+         stdout = "f1.cnew\nprog.c\n")
+test.run(program = prog2,
+         stdout = "f1.cnew\nprog.c\n")
 
 test.up_to_date(arguments = '.')