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 python = TestSCons.python
30 _python_ = TestSCons._python_
32 test = TestSCons.TestSCons()
36 test.write('build.py', r"""
38 contents = open(sys.argv[2], 'rb').read()
39 file = open(sys.argv[1], 'wb')
44 test.write('SConstruct', """
47 def buildIt(env, target, source):
48 contents = open(str(source[0]), 'rb').read()
49 file = open(str(target[0]), 'wb')
50 xyzzy = env.get('XYZZY', '')
52 file.write(xyzzy + '\\n')
57 def sub(env, target, source):
58 target = str(target[0])
59 source = str(source[0])
60 t = open(target, 'wb')
61 for f in sorted(os.listdir(source)):
62 t.write(open(os.path.join(source, f), 'rb').read())
66 env = Environment(COPY_THROUGH_TEMP = '%(_python_)s build.py .tmp $SOURCE\\n%(_python_)s build.py $TARGET .tmp',
67 EXPAND = '$COPY_THROUGH_TEMP')
68 env.Command(target = 'f1.out', source = 'f1.in',
70 env.Command(target = 'f2.out', source = 'f2.in',
71 action = r'%(_python_)s build.py temp2 $SOURCES' + '\\n' + r'%(_python_)s build.py $TARGET temp2')
72 env.Command(target = 'f3.out', source = 'f3.in',
73 action = [ [ r'%(python)s', 'build.py', 'temp3', '$SOURCES' ],
74 [ r'%(python)s', 'build.py', '$TARGET', 'temp3'] ])
75 Command(target = 'f4.out', source = 'sub', action = sub)
76 env.Command(target = 'f5.out', source = 'f5.in', action = buildIt,
78 Command(target = 'f6.out', source = 'f6.in',
79 action = r'%(_python_)s build.py f6.out f6.in')
80 env.Command(target = 'f7.out', source = 'f7.in',
81 action = r'%(_python_)s build.py $TARGET $SOURCE')
82 Command(target = 'f8.out', source = 'f8.in',
83 action = r'%(_python_)s build.py $TARGET $SOURCE')
84 env.Command(target = 'f9.out', source = 'f9.in',
86 env.Command(target = '${F10}.out', source = '${F10}.in',
87 action = r'%(_python_)s build.py $TARGET $SOURCE',
91 test.write('f1.in', "f1.in\n")
92 test.write('f2.in', "f2.in\n")
93 test.write('f3.in', "f3.in\n")
94 test.write(['sub', 'f4a'], "sub/f4a\n")
95 test.write(['sub', 'f4b'], "sub/f4b\n")
96 test.write(['sub', 'f4c'], "sub/f4c\n")
97 test.write('f5.in', "f5.in\n")
98 test.write('f6.in', "f6.in\n")
99 test.write('f7.in', "f7.in\n")
100 test.write('f8.in', "f8.in\n")
101 test.write('f9.in', "f9.in\n")
102 test.write('f10.in', "f10.in\n")
104 test.run(arguments = '.')
106 test.must_match('f1.out', "f1.in\n")
107 test.must_match('f2.out', "f2.in\n")
108 test.must_match('f3.out', "f3.in\n")
109 test.must_match('f4.out', "sub/f4a\nsub/f4b\nsub/f4c\n")
110 test.must_match('f5.out', "XYZZY is set\nf5.in\n")
111 test.must_match('f6.out', "f6.in\n")
112 test.must_match('f7.out', "f7.in\n")
113 test.must_match('f8.out', "f8.in\n")
114 test.must_match('f9.out', "f9.in\n")
115 test.must_match('f10.out', "f10.in\n")
121 # indent-tabs-mode:nil
123 # vim: set expandtab tabstop=4 shiftwidth=4: