import SCons.Scanner
import SCons.Node.FS
import SCons.Util
+import string
def ProgScan():
"""Return a prototype Scanner instance for scanning executable
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 = []
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__":
__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"""
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 = '.')