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 _shobj = TestSCons._shobj
36 test = TestSCons.TestSCons()
38 # Writing this to accomodate both our in-line tool chain and the
39 # MSVC command lines is too hard, and will be completely unnecessary
40 # some day when we separate our tests. Punt for now.
41 if sys.platform == 'win32':
42 test.skip_test('Skipping on win32.\n')
46 if sys.platform == 'win32':
48 test.write('mylink.py', r"""
56 if a[:5] == '/OUT:': out = a[5:]
57 infile = open(args[0], 'rb')
58 outfile = open(out, 'wb')
59 for l in infile.readlines():
67 test.write('mylink.py', r"""
70 opts, args = getopt.getopt(sys.argv[1:], 'o:s:')
72 if opt == '-o': out = arg
73 outfile = open(out, 'wb')
75 infile = open(f, 'rb')
76 for l in infile.readlines():
82 test.write('mygcc.py', r"""
86 compiler = sys.argv[1]
87 clen = len(compiler) + 1
88 opts, args = getopt.getopt(sys.argv[2:], 'co:xf:')
90 if opt == '-o': out = arg
91 elif opt == '-x': open('mygcc.out', 'ab').write(compiler + "\n")
92 infile = open(args[0], 'rb')
93 outfile = open(out, 'wb')
94 for l in infile.readlines():
95 if l[:clen] != '#' + compiler:
100 test.write('SConstruct', """
101 env = Environment(CPPFLAGS = '-x',
102 LINK = r'%(_python_)s mylink.py',
104 CC = r'%(_python_)s mygcc.py cc',
105 CXX = r'%(_python_)s mygcc.py c++',
107 FORTRAN = r'%(_python_)s mygcc.py g77')
108 env.Program(target = 'foo', source = Split('test1.c test2.cpp test3.F'))
111 test.write('test1.c', r"""test1.c
116 test.write('test2.cpp', r"""test2.cpp
121 test.write('test3.F', r"""test3.F
126 test.run(arguments = '.', stderr=None)
128 test.must_match('test1' + _obj, "test1.c\n#link\n")
129 test.must_match('test2' + _obj, "test2.cpp\n#link\n")
130 test.must_match('test3' + _obj, "test3.F\n#link\n")
131 test.must_match('foo' + _exe, "test1.c\ntest2.cpp\ntest3.F\n")
132 if TestSCons.case_sensitive_suffixes('.F', '.f'):
133 test.must_match('mygcc.out', "cc\nc++\ng77\n")
135 test.must_match('mygcc.out', "cc\nc++\n")
137 test.write('SConstruct', """
138 env = Environment(CPPFLAGS = '-x',
139 SHLINK = r'%(_python_)s mylink.py',
141 CC = r'%(_python_)s mygcc.py cc',
142 CXX = r'%(_python_)s mygcc.py c++',
144 FORTRAN = r'%(_python_)s mygcc.py g77')
145 env.SharedLibrary(target = File('foo.bar'),
146 source = Split('test1.c test2.cpp test3.F'))
149 test.write('test1.c', r"""test1.c
154 test.write('test2.cpp', r"""test2.cpp
159 test.write('test3.F', r"""test3.F
164 test.unlink('mygcc.out')
165 test.unlink('test1' + _obj)
166 test.unlink('test2' + _obj)
167 test.unlink('test3' + _obj)
169 test.run(arguments = '.', stderr = None)
171 test.must_match('test1' + _shobj, "test1.c\n#link\n")
172 test.must_match('test2' + _shobj, "test2.cpp\n#link\n")
173 test.must_match('test3' + _shobj, "test3.F\n#link\n")
174 test.must_match('foo.bar', "test1.c\ntest2.cpp\ntest3.F\n")
175 if TestSCons.case_sensitive_suffixes('.F', '.f'):
176 test.must_match('mygcc.out', "cc\nc++\ng77\n")
178 test.must_match('mygcc.out', "cc\nc++\n")
184 # indent-tabs-mode:nil
186 # vim: set expandtab tabstop=4 shiftwidth=4: