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 _python_ = TestSCons._python_
34 test = TestSCons.TestSCons()
38 if sys.platform == 'win32':
40 test.write('mylink.py', r"""
48 if a[:5].lower() == '/out:': out = a[5:]
49 infile = open(args[0], 'rb')
50 outfile = open(out, 'wb')
51 for l in infile.readlines():
52 if l[:8] != '/*link*/':
57 test.write('myc++.py', r"""
68 if a[:3] == '/Fo': out = a[3:]
69 infile = open(inf, 'rb')
70 outfile = open(out, 'wb')
71 for l in infile.readlines():
72 if l[:7] != '/*c++*/':
79 test.write('mylink.py', r"""
82 opts, args = getopt.getopt(sys.argv[1:], 'o:')
84 if opt == '-o': out = arg
85 infile = open(args[0], 'rb')
86 outfile = open(out, 'wb')
87 for l in infile.readlines():
88 if l[:8] != '/*link*/':
93 test.write('myc++.py', r"""
96 opts, args = getopt.getopt(sys.argv[1:], 'co:')
98 if opt == '-o': out = arg
99 infile = open(args[0], 'rb')
100 outfile = open(out, 'wb')
101 for l in infile.readlines():
102 if l[:7] != '/*c++*/':
107 test.write('SConstruct', """
108 env = Environment(LINK = r'%(_python_)s mylink.py',
110 CXX = r'%(_python_)s myc++.py',
112 env.Program(target = 'test1', source = 'test1.cc')
113 env.Program(target = 'test2', source = 'test2.cpp')
114 env.Program(target = 'test3', source = 'test3.cxx')
115 env.Program(target = 'test4', source = 'test4.c++')
116 env.Program(target = 'test5', source = 'test5.C++')
119 test.write('test1.cc', r"""This is a .cc file.
124 test.write('test2.cpp', r"""This is a .cpp file.
129 test.write('test3.cxx', r"""This is a .cxx file.
134 test.write('test4.c++', r"""This is a .c++ file.
139 test.write('test5.C++', r"""This is a .C++ file.
144 test.run(arguments = '.', stderr = None)
146 test.must_match('test1' + _exe, "This is a .cc file.\n")
148 test.must_match('test2' + _exe, "This is a .cpp file.\n")
150 test.must_match('test3' + _exe, "This is a .cxx file.\n")
152 test.must_match('test4' + _exe, "This is a .c++ file.\n")
154 test.must_match('test5' + _exe, "This is a .C++ file.\n")
156 if TestSCons.case_sensitive_suffixes('.c', '.C'):
158 test.write('SConstruct', """
159 env = Environment(LINK = r'%(_python_)s mylink.py',
161 CXX = r'%(_python_)s myc++.py',
163 env.Program(target = 'test6', source = 'test6.C')
166 test.write('test6.C', r"""This is a .C file.
171 test.run(arguments = '.', stderr = None)
173 test.must_match('test6' + _exe, "This is a .C file.\n")
178 test.write("wrapper.py",
181 open('%s', 'wb').write("wrapper.py\\n")
182 os.system(" ".join(sys.argv[1:]))
183 """ % test.workpath('wrapper.out').replace('\\', '\\\\'))
185 test.write('SConstruct', """
187 cxx = foo.Dictionary('CXX')
188 bar = Environment(CXX = r'%(_python_)s wrapper.py ' + cxx)
189 foo.Program(target = 'foo', source = 'foo.cxx')
190 bar.Program(target = 'bar', source = 'bar.cxx')
193 test.write('foo.cxx', r"""
197 main(int argc, char *argv[])
199 argv[argc++] = (char *)"--";
205 test.write('bar.cxx', r"""
209 main(int argc, char *argv[])
211 argv[argc++] = (char *)"--";
218 test.run(arguments = 'foo' + _exe)
220 test.must_not_exist(test.workpath('wrapper.out'))
222 test.run(arguments = 'bar' + _exe)
224 test.must_match('wrapper.out', "wrapper.py\n")
230 # indent-tabs-mode:nil
232 # vim: set expandtab tabstop=4 shiftwidth=4: