From 1f0c49dc905310ce09cc790ba2d2b438d07fd846 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 23 Jan 2002 22:33:07 +0000 Subject: Handle LIBPATH as a string (Crain). --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Scanner/Prog.py | 7 ++++-- src/engine/SCons/Scanner/ProgTests.py | 10 +++++++++ test/LIBPATH.py | 42 ++++++++++++++++++++++++++++++++++- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 44946a0..ea9bf43 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 0182cda..2ca28f2 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -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 = [] diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 6c3f5e4..e376557 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -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__": diff --git a/test/LIBPATH.py b/test/LIBPATH.py index a373425..68e83e1 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -25,14 +25,30 @@ __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 = '.') -- cgit v0.12