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__"
29 test
= TestSCons
.TestSCons()
31 test
.subdir('foo', ['foo', 'zzz'], 'bar', ['bar', 'yyy'], 'work')
33 workpath_foo
= test
.workpath('foo')
34 workpath_foo_yyy
= test
.workpath('foo', 'yyy')
35 workpath_foo_zzz
= test
.workpath('foo', 'zzz')
36 workpath_bar
= test
.workpath('bar')
37 workpath_bar_yyy
= test
.workpath('bar', 'yyy')
38 workpath_bar_zzz
= test
.workpath('bar', 'zzz')
39 workpath_work
= test
.workpath('work')
41 test
.write(['work', 'SConstruct'], r
"""
42 env_zzz = Environment(LIBPATH = ['.', 'zzz'])
43 env_yyy = Environment(LIBPATH = ['yyy', '.'])
44 aaa_exe = env_zzz.Program('aaa', 'aaa.c')
45 bbb_exe = env_yyy.Program('bbb', 'bbb.c')
46 def write_LIBDIRFLAGS(env, target, source):
47 pre = env.subst('$LIBDIRPREFIX')
48 suf = env.subst('$LIBDIRSUFFIX')
49 with open(str(target[0]), 'w') as f:
50 for arg in env.subst('$_LIBDIRFLAGS', target=target).split():
51 if arg[:len(pre)] == pre:
53 if arg[-len(suf):] == suf:
57 env_zzz.Command('zzz.out', aaa_exe, write_LIBDIRFLAGS)
58 env_yyy.Command('yyy.out', bbb_exe, write_LIBDIRFLAGS)
60 if env_yyy['PLATFORM'] == 'darwin':
61 # The Mac OS X linker complains about nonexistent directories
62 # specified as -L arguments. Suppress its warnings so we don't
63 # treat the warnings on stderr as a failure.
64 env_yyy.Append(LINKFLAGS=['-w'])
65 env_zzz.Append(LINKFLAGS=['-w'])
68 test
.write(['work', 'aaa.c'], r
"""
72 main(int argc, char *argv[])
75 printf("work/aaa.c\n");
80 test
.write(['work', 'bbb.c'], r
"""
84 main(int argc, char *argv[])
87 printf("work/bbb.c\n");
93 opts
= "-Y %s -Y %s -Y %s" % (workpath_foo
, workpath_work
, workpath_bar
)
94 test
.run(chdir
= 'work', options
= opts
, arguments
= ".")
96 #dirs = ['.', workpath_foo, workpath_bar, workpath_foo_zzz]
97 dirs
= ['.', workpath_foo
, workpath_bar
,
98 'zzz', workpath_foo_zzz
, workpath_bar_zzz
]
99 test
.must_match(['work', 'zzz.out'],'\n'.join(dirs
) + '\n', mode
='r')
101 #dirs = [workpath_bar_yyy, '.', workpath_foo, workpath_bar]
102 dirs
= ['yyy', workpath_foo_yyy
, workpath_bar_yyy
,
103 '.', workpath_foo
, workpath_bar
]
104 test
.must_match(['work', 'yyy.out'], '\n'.join(dirs
) + '\n', mode
='r')
107 test
.run(chdir
= 'work', options
= '-c', arguments
= ".")
109 test
.subdir(['work', 'zzz'], ['work', 'yyy'])
112 test
.run(chdir
= 'work', options
= opts
, arguments
= ".")
114 #dirs = ['.', workpath_foo, workpath_bar, 'zzz', workpath_foo_zzz]
115 dirs
= ['.', workpath_foo
, workpath_bar
,
116 'zzz', workpath_foo_zzz
, workpath_bar_zzz
]
117 test
.must_match(['work', 'zzz.out'], '\n'.join(dirs
) + '\n', mode
='r')
119 #dirs = ['yyy', workpath_bar_yyy, '.', workpath_foo, workpath_bar]
120 dirs
= ['yyy', workpath_foo_yyy
, workpath_bar_yyy
,
121 '.', workpath_foo
, workpath_bar
]
122 test
.must_match(['work', 'yyy.out'], '\n'.join(dirs
) + '\n', mode
='r')
129 # indent-tabs-mode:nil
131 # vim: set expandtab tabstop=4 shiftwidth=4: