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 _shobj = TestSCons._shobj
37 test = TestSCons.TestSCons()
39 # Writing this to accomodate both our in-line tool chain and the
40 # MSVC command lines is too hard, and will be completely unnecessary
41 # some day when we separate our tests. Punt for now.
42 test.no_result(sys.platform == 'win32')
46 if sys.platform == 'win32':
48 test.write('mylink.py', r"""
58 if a[:5] == '/OUT:': out = a[5:]
59 infile = open(args[0], 'rb')
60 outfile = open(out, 'wb')
61 for l in infile.readlines():
69 test.write('mylink.py', r"""
73 opts, args = getopt.getopt(sys.argv[1:], 'o:s:')
75 if opt == '-o': out = arg
76 outfile = open(out, 'wb')
78 infile = open(f, 'rb')
79 for l in infile.readlines():
85 test.write('mygcc.py', r"""
89 compiler = sys.argv[1]
90 clen = len(compiler) + 1
91 opts, args = getopt.getopt(sys.argv[2:], 'co:xf:')
93 if opt == '-o': out = arg
94 elif opt == '-x': open('mygcc.out', 'ab').write(compiler + "\n")
95 infile = open(args[0], 'rb')
96 outfile = open(out, 'wb')
97 for l in infile.readlines():
98 if l[:clen] != '#' + compiler:
103 test.write('SConstruct', """
104 env = Environment(CPPFLAGS = '-x',
105 LINK = r'%s mylink.py',
107 CC = r'%s mygcc.py cc',
108 CXX = r'%s mygcc.py c++',
110 FORTRAN = r'%s mygcc.py g77')
111 env.Program(target = 'foo', source = Split('test1.c test2.cpp test3.F'))
112 """ % (python, python, python, python))
114 test.write('test1.c', r"""test1.c
119 test.write('test2.cpp', r"""test2.cpp
124 test.write('test3.F', r"""test3.F
129 test.run(arguments = '.', stderr=None)
131 test.must_match('test1' + _obj, "test1.c\n#link\n")
132 test.must_match('test2' + _obj, "test2.cpp\n#link\n")
133 test.must_match('test3' + _obj, "test3.F\n#link\n")
134 test.must_match('foo' + _exe, "test1.c\ntest2.cpp\ntest3.F\n")
135 if TestSCons.case_sensitive_suffixes('.F', '.f'):
136 test.must_match('mygcc.out', "cc\nc++\ng77\n")
138 test.must_match('mygcc.out', "cc\nc++\n")
140 test.write('SConstruct', """
141 env = Environment(CPPFLAGS = '-x',
142 SHLINK = r'%s mylink.py',
144 CC = r'%s mygcc.py cc',
145 CXX = r'%s mygcc.py c++',
147 FORTRAN = r'%s mygcc.py g77')
148 env.SharedLibrary(target = File('foo.bar'),
149 source = Split('test1.c test2.cpp test3.F'))
150 """ % (python, python, python, python))
152 test.write('test1.c', r"""test1.c
157 test.write('test2.cpp', r"""test2.cpp
162 test.write('test3.F', r"""test3.F
167 test.unlink('mygcc.out')
168 test.unlink('test1' + _obj)
169 test.unlink('test2' + _obj)
170 test.unlink('test3' + _obj)
172 test.run(arguments = '.', stderr = None)
174 test.must_match('test1' + _shobj, "test1.c\n#link\n")
175 test.must_match('test2' + _shobj, "test2.cpp\n#link\n")
176 test.must_match('test3' + _shobj, "test3.F\n#link\n")
177 test.must_match('foo.bar', "test1.c\ntest2.cpp\ntest3.F\n")
178 if TestSCons.case_sensitive_suffixes('.F', '.f'):
179 test.must_match('mygcc.out', "cc\nc++\ng77\n")
181 test.must_match('mygcc.out', "cc\nc++\n")