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__"
34 subdir_prog = os.path.join('subdir', 'prog' + _exe)
35 variant_prog = os.path.join('variant', 'prog' + _exe)
37 args = prog + ' ' + subdir_prog + ' ' + variant_prog
39 test = TestSCons.TestSCons()
44 ['subdir', 'include'],
47 test.write('SConstruct', """
48 env = Environment(CPPPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
50 obj = env.Object(target='foobar/prog', source='subdir/prog.c')
51 env.Program(target='prog', source=obj)
52 SConscript('subdir/SConscript', "env")
54 VariantDir('variant', 'subdir', 0)
55 include = Dir('include')
56 env = Environment(CPPPATH=[include, '#foobar', '#subdir'])
57 SConscript('variant/SConscript', "env")
60 test.write(['subdir', 'SConscript'],
63 env.Program(target='prog', source='prog.c')
66 test.write(['include', 'foo.h'],
68 #define FOO_STRING "include/foo.h 1\n"
72 test.write(['include', 'bar.h'],
74 #define BAR_STRING "include/bar.h 1\n"
77 test.write(['subdir', 'sss.h'],
79 #define SSS_STRING "subdir/sss.h\n"
82 test.write(['foobar', 'ttt.h'],
84 #define TTT_STRING "foobar/ttt.h\n"
87 test.write(['subdir', 'ttt.h'],
89 #define TTT_STRING "subdir/ttt.h\n"
92 test.write(['subdir', 'prog.c'],
100 main(int argc, char *argv[])
103 printf("subdir/prog.c\n");
112 test.write(['subdir', 'include', 'foo.h'],
114 #define FOO_STRING "subdir/include/foo.h 1\n"
118 test.write(['subdir', 'include', 'bar.h'],
120 #define BAR_STRING "subdir/include/bar.h 1\n"
125 test.run(arguments = args)
127 test.run(program = test.workpath(prog),
136 test.run(program = test.workpath(subdir_prog),
139 subdir/include/foo.h 1
140 subdir/include/bar.h 1
145 test.run(program = test.workpath(variant_prog),
156 # Make sure we didn't duplicate the source file in the variant subdirectory.
157 test.must_not_exist(test.workpath('variant', 'prog.c'))
159 test.up_to_date(arguments = args)
161 test.write(['include', 'foo.h'],
163 #define FOO_STRING "include/foo.h 2\n"
167 test.run(arguments = args)
169 test.run(program = test.workpath(prog),
178 test.run(program = test.workpath(subdir_prog),
181 subdir/include/foo.h 1
182 subdir/include/bar.h 1
187 test.run(program = test.workpath(variant_prog),
198 # Make sure we didn't duplicate the source file in the variant subdirectory.
199 test.must_not_exist(test.workpath('variant', 'prog.c'))
201 test.up_to_date(arguments = args)
206 test.write(['include', 'bar.h'],
208 #define BAR_STRING "include/bar.h 2\n"
211 test.run(arguments = args)
213 test.run(program = test.workpath(prog),
222 test.run(program = test.workpath(subdir_prog),
225 subdir/include/foo.h 1
226 subdir/include/bar.h 1
231 test.run(program = test.workpath(variant_prog),
240 # Make sure we didn't duplicate the source file in the variant subdirectory.
241 test.must_not_exist(test.workpath('variant', 'prog.c'))
243 test.up_to_date(arguments = args)
247 # Change CPPPATH and make sure we don't rebuild because of it.
248 test.write('SConstruct', """
249 env = Environment(CPPPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'))
250 obj = env.Object(target='foobar/prog', source='subdir/prog.c')
251 env.Program(target='prog', source=obj)
252 SConscript('subdir/SConscript', "env")
254 VariantDir('variant', 'subdir', 0)
255 include = Dir('include')
256 env = Environment(CPPPATH=['inc2', include, '#foobar', '#subdir'])
257 SConscript('variant/SConscript', "env")
260 test.up_to_date(arguments = args)
265 test.write(['inc2', 'foo.h'],
267 #define FOO_STRING "inc2/foo.h 1\n"
271 test.run(arguments = args)
273 test.run(program = test.workpath(prog),
282 test.run(program = test.workpath(subdir_prog),
285 subdir/include/foo.h 1
286 subdir/include/bar.h 1
291 test.run(program = test.workpath(variant_prog),
300 test.up_to_date(arguments = args)
308 # indent-tabs-mode:nil
310 # vim: set expandtab tabstop=4 shiftwidth=4: