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__"
31 test = TestSCons.TestSCons()
35 test.write('SConstruct',"""
36 VariantDir('var1', 'src', duplicate=0)
37 VariantDir('var2', 'src', duplicate=1)
38 SConscript('src/SConscript')
39 SConscript('var1/SConscript')
40 SConscript('var2/SConscript')
43 test.write('src/SConscript',"""
44 def build(target, source, env):
46 open(str(t), "wt").write(str(t))
48 def emitter(target, source, env):
49 target.append(str(target[0])+".foo")
52 def emit1(t, s, e): return (t + ['emit.1'], s)
53 def emit2(t, s, e): return (t + ['emit.2'], s)
55 foo = Builder(action=build, emitter=emitter)
56 bar = Builder(action=build, emitter='$EMITTERS')
58 env=Environment(BUILDERS={ 'foo': foo, 'bar': bar },
59 EMITTERS=[emit1, emit2])
60 env.foo('f.out', 'f.in')
61 env.foo(File('g.out'), 'g.in')
62 env.bar('h.out', 'h.in')
65 test.write(['src', 'f.in'], 'f.in')
66 test.write(['src', 'g.in'], 'g.in')
67 test.write(['src', 'h.in'], 'h.in')
69 # Do 'src' last so that creation of the emitter files in there doesn't
70 # interfere with searching for them in the VariantDirs.
72 test.run(arguments='var2')
74 test.must_exist(test.workpath('var2', 'f.out'))
75 test.must_exist(test.workpath('var2', 'f.out.foo'))
76 test.must_exist(test.workpath('var2', 'g.out'))
77 test.must_exist(test.workpath('var2', 'g.out.foo'))
78 test.must_exist(test.workpath('var2', 'h.out'))
79 test.must_exist(test.workpath('var2', 'emit.1'))
80 test.must_exist(test.workpath('var2', 'emit.2'))
82 test.run(arguments = 'var1')
84 test.must_exist(test.workpath('var1', 'f.out'))
85 test.must_exist(test.workpath('var1', 'f.out.foo'))
86 test.must_exist(test.workpath('var1', 'g.out'))
87 test.must_exist(test.workpath('var1', 'g.out.foo'))
88 test.must_exist(test.workpath('var1', 'h.out'))
89 test.must_exist(test.workpath('var1', 'emit.1'))
90 test.must_exist(test.workpath('var1', 'emit.2'))
92 test.run(arguments = 'src')
94 test.must_exist(test.workpath('src', 'f.out'))
95 test.must_exist(test.workpath('src', 'f.out.foo'))
96 test.must_exist(test.workpath('src', 'g.out'))
97 test.must_exist(test.workpath('src', 'g.out.foo'))
98 test.must_exist(test.workpath('src', 'h.out'))
99 test.must_exist(test.workpath('src', 'emit.1'))
100 test.must_exist(test.workpath('src', 'emit.2'))