diff options
author | Steven Knight <knight@baldmt.com> | 2004-04-02 05:15:17 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-04-02 05:15:17 (GMT) |
commit | 9175dc608055e832800472992feec71de3540f1a (patch) | |
tree | e01f6f7a9f49e22157c9d1d6c60c097e61439ef3 | |
parent | 7d79f5147981e3af937f5e0293ad2a7ea8bdfd70 (diff) | |
download | SCons-9175dc608055e832800472992feec71de3540f1a.zip SCons-9175dc608055e832800472992feec71de3540f1a.tar.gz SCons-9175dc608055e832800472992feec71de3540f1a.tar.bz2 |
Allow environment substitutions when referencing libraries. (Chad Austin)
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/Prog.py | 1 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/ProgTests.py | 19 | ||||
-rw-r--r-- | test/Library.py | 28 |
4 files changed, 50 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b323e08..0e4d4d8 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -14,6 +14,8 @@ RELEASE 0.96 - XXX - Make the CacheDir() directory if it doesn't already exist. + - Allow construction variable substitutions in $LIBS specifications. + From Tom Epperly: - Allow the Java() Builder to take more than one source directory. diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 0100b3d..3c45ca2 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -76,6 +76,7 @@ def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs): 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: diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 4e10488..f3a2755 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -71,6 +71,11 @@ class DummyEnvironment: 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): @@ -167,6 +172,19 @@ class ProgScanTestCase6(unittest.TestCase): 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()) @@ -174,6 +192,7 @@ def suite(): suite.addTest(ProgScanTestCase3()) suite.addTest(ProgScanTestCase5()) suite.addTest(ProgScanTestCase6()) + suite.addTest(ProgScanTestCase7()) if hasattr(types, 'UnicodeType'): code = """if 1: class ProgScanTestCase4(unittest.TestCase): diff --git a/test/Library.py b/test/Library.py index 37641a8..f22172c 100644 --- a/test/Library.py +++ b/test/Library.py @@ -126,4 +126,32 @@ test.run(arguments = '.') 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() |