Revert revision 4742. How hard is it to understand "No bugfixes in 2.0"?
[scons.git] / test / CXX / SHCXXCOMSTR.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 that the $SHCXXCOMSTR construction variable allows you to customize
29 the shared object C++ compilation output.
30 """
31
32 import TestSCons
33
34 _python_ = TestSCons._python_
35 _exe   = TestSCons._exe
36
37 test = TestSCons.TestSCons()
38
39
40
41 test.write('mycc.py', r"""
42 import sys
43 outfile = open(sys.argv[1], 'wb')
44 infile = open(sys.argv[2], 'rb')
45 for l in [l for l in infile.readlines() if l != '/*c++*/\n']:
46     outfile.write(l)
47 sys.exit(0)
48 """)
49
50 alt_cpp_suffix=test.get_alt_cpp_suffix()
51
52 test.write('SConstruct', """
53 env = Environment(SHCXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
54                   SHCXXCOMSTR = 'Building shared object $TARGET from $SOURCE',
55                   SHOBJPREFIX='', SHOBJSUFFIX='.obj')
56 env.SharedObject(target = 'test1', source = 'test1.cpp')
57 env.SharedObject(target = 'test2', source = 'test2.cc')
58 env.SharedObject(target = 'test3', source = 'test3.cxx')
59 env.SharedObject(target = 'test4', source = 'test4.c++')
60 env.SharedObject(target = 'test5', source = 'test5.C++')
61 env.SharedObject(target = 'test6', source = 'test6%(alt_cpp_suffix)s')
62 """ % locals())
63
64 test.write('test1.cpp', "test1.cpp\n/*c++*/\n")
65 test.write('test2.cc',  "test2.cc\n/*c++*/\n")
66 test.write('test3.cxx', "test3.cxx\n/*c++*/\n")
67 test.write('test4.c++', "test4.c++\n/*c++*/\n")
68 test.write('test5.C++', "test5.C++\n/*c++*/\n")
69 test.write('test6'+alt_cpp_suffix, "test6.C\n/*c++*/\n")
70
71 test.run(stdout = test.wrap_stdout("""\
72 Building shared object test1.obj from test1.cpp
73 Building shared object test2.obj from test2.cc
74 Building shared object test3.obj from test3.cxx
75 Building shared object test4.obj from test4.c++
76 Building shared object test5.obj from test5.C++
77 Building shared object test6.obj from test6%(alt_cpp_suffix)s
78 """ % locals()))
79
80 test.must_match('test1.obj', "test1.cpp\n")
81 test.must_match('test2.obj', "test2.cc\n")
82 test.must_match('test3.obj', "test3.cxx\n")
83 test.must_match('test4.obj', "test4.c++\n")
84 test.must_match('test5.obj', "test5.C++\n")
85 test.must_match('test6.obj', "test6.C\n")
86
87
88
89 test.pass_test()
90
91 # Local Variables:
92 # tab-width:4
93 # indent-tabs-mode:nil
94 # End:
95 # vim: set expandtab tabstop=4 shiftwidth=4: