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__"
32 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
39 if sys.platform == 'win32':
41 test.write('mylink.py', r"""
50 if string.lower(a[:5]) == '/out:': out = a[5:]
51 infile = open(args[0], 'rb')
52 outfile = open(out, 'wb')
53 for l in infile.readlines():
54 if l[:8] != '/*link*/':
59 test.write('myc++.py', r"""
70 if a[:3] == '/Fo': out = a[3:]
71 infile = open(inf, 'rb')
72 outfile = open(out, 'wb')
73 for l in infile.readlines():
74 if l[:7] != '/*c++*/':
81 test.write('mylink.py', r"""
84 opts, args = getopt.getopt(sys.argv[1:], 'o:')
86 if opt == '-o': out = arg
87 infile = open(args[0], 'rb')
88 outfile = open(out, 'wb')
89 for l in infile.readlines():
90 if l[:8] != '/*link*/':
95 test.write('myc++.py', r"""
98 opts, args = getopt.getopt(sys.argv[1:], 'co:')
100 if opt == '-o': out = arg
101 infile = open(args[0], 'rb')
102 outfile = open(out, 'wb')
103 for l in infile.readlines():
104 if l[:7] != '/*c++*/':
109 test.write('SConstruct', """
110 env = Environment(LINK = r'%(_python_)s mylink.py',
112 CXX = r'%(_python_)s myc++.py',
114 env.Program(target = 'test1', source = 'test1.cc')
115 env.Program(target = 'test2', source = 'test2.cpp')
116 env.Program(target = 'test3', source = 'test3.cxx')
117 env.Program(target = 'test4', source = 'test4.c++')
118 env.Program(target = 'test5', source = 'test5.C++')
121 test.write('test1.cc', r"""This is a .cc file.
126 test.write('test2.cpp', r"""This is a .cpp file.
131 test.write('test3.cxx', r"""This is a .cxx file.
136 test.write('test4.c++', r"""This is a .c++ file.
141 test.write('test5.C++', r"""This is a .C++ file.
146 test.run(arguments = '.', stderr = None)
148 test.must_match('test1' + _exe, "This is a .cc file.\n")
150 test.must_match('test2' + _exe, "This is a .cpp file.\n")
152 test.must_match('test3' + _exe, "This is a .cxx file.\n")
154 test.must_match('test4' + _exe, "This is a .c++ file.\n")
156 test.must_match('test5' + _exe, "This is a .C++ file.\n")
158 if TestSCons.case_sensitive_suffixes('.c', '.C'):
160 test.write('SConstruct', """
161 env = Environment(LINK = r'%(_python_)s mylink.py',
163 CXX = r'%(_python_)s myc++.py',
165 env.Program(target = 'test6', source = 'test6.C')
168 test.write('test6.C', r"""This is a .C file.
173 test.run(arguments = '.', stderr = None)
175 test.must_match('test6' + _exe, "This is a .C file.\n")
180 test.write("wrapper.py",
184 open('%s', 'wb').write("wrapper.py\\n")
185 os.system(string.join(sys.argv[1:], " "))
186 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
188 test.write('SConstruct', """
190 cxx = foo.Dictionary('CXX')
191 bar = Environment(CXX = r'%(_python_)s wrapper.py ' + cxx)
192 foo.Program(target = 'foo', source = 'foo.cxx')
193 bar.Program(target = 'bar', source = 'bar.cxx')
196 test.write('foo.cxx', r"""
200 main(int argc, char *argv[])
202 argv[argc++] = (char *)"--";
208 test.write('bar.cxx', r"""
212 main(int argc, char *argv[])
214 argv[argc++] = (char *)"--";
221 test.run(arguments = 'foo' + _exe)
223 test.must_not_exist(test.workpath('wrapper.out'))
225 test.run(arguments = 'bar' + _exe)
227 test.must_match('wrapper.out', "wrapper.py\n")