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.
26 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
32 test = TestSCons.TestSCons()
36 sub_f3_out = os.path.join('sub', 'f3.out')
37 _SUBDIR_f3_out = os.path.join('$SUBDIR', 'f3.out')
39 test.write('SConstruct', """\
40 def bfunc(target, source, env):
42 shutil.copyfile('f2.in', str(target[0]))
44 B = Builder(action=bfunc)
45 env = Environment(BUILDERS = { 'B' : B }, SUBDIR='sub')
46 env.B('f1.out', source='f1.in')
49 env.B(r'%(sub_f3_out)s', source='f3.in')
50 env.AlwaysBuild(r'%(_SUBDIR_f3_out)s')
52 env.Alias('clean1', [], Delete('clean1-target'))
53 env.AlwaysBuild('clean1')
54 c2 = env.Alias('clean2', [], [Delete('clean2-t1'), Delete('clean2-t2')])
57 def dir_build(target, source, env):
58 open('dir_build.txt', 'ab').write('dir_build()\\n')
59 env.Command(Dir('dir'), None, dir_build)
60 env.AlwaysBuild('dir')
63 test.write('f1.in', "f1.in\n")
64 test.write('f2.in', "1")
65 test.write('f3.in', "f3.in\n")
69 test.run(arguments = ".")
70 test.must_match('f1.out', '1')
71 test.must_match(['sub', 'f3.out'], '1')
72 test.must_match('dir_build.txt', "dir_build()\n")
74 test.write('f2.in', "2")
76 test.run(arguments = ".")
77 test.must_match('f1.out', '2')
78 test.must_match(['sub', 'f3.out'], '2')
79 test.must_match('dir_build.txt', "dir_build()\ndir_build()\n")
81 test.run(arguments = 'clean1', stdout=test.wrap_stdout("""\
82 Delete("clean1-target")
85 test.run(arguments = 'clean2', stdout=test.wrap_stdout("""\
90 test.not_up_to_date(arguments = 'dir')
92 test.must_match('dir_build.txt', "dir_build()\ndir_build()\ndir_build()\n")
98 # indent-tabs-mode:nil
100 # vim: set expandtab tabstop=4 shiftwidth=4: