Revert revision 4742. How hard is it to understand "No bugfixes in 2.0"?
[scons.git] / test / CXX / CXXCOM.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test the ability to configure the $CXXCOM construction variable.
29 """
30
31 import TestSCons
32
33 _python_ = TestSCons._python_
34 _exe   = TestSCons._exe
35
36 test = TestSCons.TestSCons()
37
38
39
40 test.write('mycc.py', r"""
41 import sys
42 outfile = open(sys.argv[1], 'wb')
43 infile = open(sys.argv[2], 'rb')
44 for l in [l for l in infile.readlines() if l[:7] != '/*c++*/']:
45     outfile.write(l)
46 sys.exit(0)
47 """)
48
49 alt_cpp_suffix=test.get_alt_cpp_suffix()
50
51 test.write('SConstruct', """
52 env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
53                   OBJSUFFIX='.obj')
54 env.Object(target = 'test1', source = 'test1.cpp')
55 env.Object(target = 'test2', source = 'test2.cc')
56 env.Object(target = 'test3', source = 'test3.cxx')
57 env.Object(target = 'test4', source = 'test4.c++')
58 env.Object(target = 'test5', source = 'test5.C++')
59 env.Object(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
60 """ % locals())
61
62 test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
63 test.write('test2.cc',  "test2.cc\n/*c++*/\n")
64 test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
65 test.write('test4.c++', "test4.c++\n/*c++*/\n")
66 test.write('test5.C++', "test5.C++\n/*c++*/\n")
67 test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
68
69 test.run()
70
71 test.must_match('test1.obj', "test1.cpp\n")
72 test.must_match('test2.obj', "test2.cc\n")
73 test.must_match('test3.obj', "test3.cxx\n")
74 test.must_match('test4.obj', "test4.c++\n")
75 test.must_match('test5.obj', "test5.C++\n")
76 test.must_match('test6.obj', "test6.C\n")
77
78
79
80 test.pass_test()
81
82 # Local Variables:
83 # tab-width:4
84 # indent-tabs-mode:nil
85 # End:
86 # vim: set expandtab tabstop=4 shiftwidth=4: