5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30 test = TestSCons.TestSCons()
32 test.subdir('foo', ['foo', 'zzz'], 'bar', ['bar', 'yyy'], 'work')
34 workpath_foo = test.workpath('foo')
35 workpath_foo_yyy = test.workpath('foo', 'yyy')
36 workpath_foo_zzz = test.workpath('foo', 'zzz')
37 workpath_bar = test.workpath('bar')
38 workpath_bar_yyy = test.workpath('bar', 'yyy')
39 workpath_bar_zzz = test.workpath('bar', 'zzz')
40 workpath_work = test.workpath('work')
42 test.write(['work', 'SConstruct'], r"""
44 env_zzz = Environment(LIBPATH = ['.', 'zzz'])
45 env_yyy = Environment(LIBPATH = ['yyy', '.'])
46 aaa_exe = env_zzz.Program('aaa', 'aaa.c')
47 bbb_exe = env_yyy.Program('bbb', 'bbb.c')
48 def write_LIBDIRFLAGS(env, target, source):
49 pre = env.subst('$LIBDIRPREFIX')
50 suf = env.subst('$LIBDIRSUFFIX')
51 f = open(str(target[0]), 'wb')
52 for arg in string.split(env.subst('$_LIBDIRFLAGS')):
53 if arg[:len(pre)] == pre:
55 if arg[-len(suf):] == suf:
60 env_zzz.Command('zzz.out', aaa_exe, write_LIBDIRFLAGS)
61 env_yyy.Command('yyy.out', bbb_exe, write_LIBDIRFLAGS)
64 test.write(['work', 'aaa.c'], r"""
66 main(int argc, char *argv[])
69 printf("work/aaa.c\n");
74 test.write(['work', 'bbb.c'], r"""
76 main(int argc, char *argv[])
79 printf("work/bbb.c\n");
85 opts = "-Y %s -Y %s -Y %s" % (workpath_foo, workpath_work, workpath_bar)
86 test.run(chdir = 'work', options = opts, arguments = ".")
88 #dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz]
89 dirs = ['.', workpath_foo, workpath_bar,
90 'zzz', workpath_foo_zzz, workpath_bar_zzz]
91 test.fail_test(test.read(['work', 'zzz.out']) !=
92 string.join(dirs, '\n') + '\n')
94 #dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar]
95 dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy,
96 '.', workpath_foo, workpath_bar]
97 test.fail_test(test.read(['work', 'yyy.out']) !=
98 string.join(dirs, '\n') + '\n')
101 test.run(chdir = 'work', options = '-c', arguments = ".")
103 test.subdir(['work', 'zzz'], ['work', 'yyy'])
106 test.run(chdir = 'work', options = opts, arguments = ".")
108 #dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz]
109 dirs = ['.', workpath_foo, workpath_bar,
110 'zzz', workpath_foo_zzz, workpath_bar_zzz]
111 test.fail_test(test.read(['work', 'zzz.out']) !=
112 string.join(dirs, '\n') + '\n')
114 #dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar]
115 dirs = ['yyy', workpath_foo_yyy, workpath_bar_yyy,
116 '.', workpath_foo, workpath_bar]
117 test.fail_test(test.read(['work', 'yyy.out']) !=
118 string.join(dirs, '\n') + '\n')