for pref in map(env.subst, prefix):
for lib in libs:
if SCons.Util.is_String(lib):
+ lib = env.subst(lib)
lib = adjustixes(lib, pref, suf)
lib = find_file(lib, libpath, fs.File)
if lib:
del self.Dictionary()[key]
def subst(self, s):
+ try:
+ if s[0] == '$':
+ return self._dict[s[1:]]
+ except IndexError:
+ return ''
return s
def subst_path(self, path):
deps = s('dummy', env, path)
assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
+class ProgScanTestCase7(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
+ LIBS=['foo', '$LIBBAR', '$XYZ'],
+ LIBPREFIXES=['lib'],
+ LIBSUFFIXES=['.a'],
+ LIBBAR='sub/libbar',
+ XYZ='xyz.other')
+ s = SCons.Scanner.Prog.ProgScan()
+ path = s.path(env)
+ deps = s('dummy', env, path)
+ assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
+
def suite():
suite = unittest.TestSuite()
suite.addTest(ProgScanTestCase1())
suite.addTest(ProgScanTestCase3())
suite.addTest(ProgScanTestCase5())
suite.addTest(ProgScanTestCase6())
+ suite.addTest(ProgScanTestCase7())
if hasattr(types, 'UnicodeType'):
code = """if 1:
class ProgScanTestCase4(unittest.TestCase):
test.run(program = test.workpath('prog'),
stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.cpp\nprog.c\n")
+# Tests whether you can reference libraries with substitutions.
+
+test.write('SConstruct', r"""
+# nrd = not referenced directly :)
+Library('nrd', 'nrd.c')
+p = Program('uses-nrd', 'uses-nrd.c', NRD='nrd', LIBPATH=['.'], LIBS=['$NRD'])
+Default(p)
+""")
+
+test.write('nrd.c', r"""
+#include <stdio.h>
+void nrd() {
+ puts("nrd");
+}
+""")
+
+test.write('uses-nrd.c', r"""
+void nrd();
+int main() {
+ nrd();
+ return 0;
+}
+""")
+
+test.run()
+test.run(program = test.workpath('uses-nrd'),
+ stdout = "nrd\n")
+
test.pass_test()