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 test = TestSCons.TestSCons()
34 test.write('SConstruct', """
36 env=Environment(WINDOWS_INSERT_DEF=1)
37 env2 = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ],
39 env.SharedLibrary(target = 'foo1', source = 'f1.c')
40 if sys.platform == 'win32':
41 env.StaticLibrary(target = 'foo1-static', source = 'f1.c')
43 env.StaticLibrary(target = 'foo1', source = 'f1.c')
44 SharedLibrary(target = 'foo2',
45 source = Split('f2a.c f2b.c f2c.c'),
46 WINDOWS_INSERT_DEF = 1)
47 env.SharedLibrary(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
48 env2.Program(target = 'prog', source = 'prog.c')
51 test.write('SConstructFoo', """
53 obj = env.Object('foo', 'foo.c')
54 Default(env.SharedLibrary(target = 'foo', source = obj))
57 test.write('SConstructFoo2', """
59 obj = env.SharedObject('bar', 'foo.c')
60 Default(env.Library(target = 'foo', source = obj))
63 test.write('foo.c', r"""
75 test.write('f1.c', r"""
86 test.write("foo1.def", r"""
88 DESCRIPTION "Foo1 Shared Library"
94 test.write('f2a.c', r"""
104 test.write('f2b.c', r"""
113 test.write('f2c.c', r"""
124 test.write("foo2.def", r"""
126 DESCRIPTION "Foo2 Shared Library"
134 test.write('f3a.c', r"""
143 test.write('f3b.c', r"""
152 test.write('f3c.c', r"""
163 test.write("foo3.def", r"""
165 DESCRIPTION "Foo3 Shared Library"
173 test.write('prog.c', r"""
183 main(int argc, char *argv[])
198 test.run(arguments = '.',
199 stderr=TestSCons.noisy_ar,
200 match=TestSCons.match_re_dotall)
202 if os.name == 'posix':
203 os.environ['LD_LIBRARY_PATH'] = '.'
204 if sys.platform.find('irix') != -1:
205 os.environ['LD_LIBRARYN32_PATH'] = '.'
207 test.run(program = test.workpath('prog'),
208 stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n")
210 if sys.platform == 'win32' or sys.platform.find('irix') != -1:
211 test.run(arguments = '-f SConstructFoo')
213 test.run(arguments = '-f SConstructFoo', status=2, stderr='''\
214 scons: \*\*\* \[.*\] Source file: foo\..* is static and is not compatible with shared target: .*
216 match=TestSCons.match_re_dotall)
217 # Run it again to make sure that we still get the error
218 # even though the static objects already exist.
219 test.run(arguments = '-f SConstructFoo', status=2, stderr='''\
220 scons: \*\*\* \[.*\] Source file: foo\..* is static and is not compatible with shared target: .*
222 match=TestSCons.match_re_dotall)
224 test.run(arguments = '-f SConstructFoo2',
225 stderr=TestSCons.noisy_ar,
226 match=TestSCons.match_re_dotall)
228 if sys.platform == 'win32':
229 # Make sure we don't insert a .def source file (when
230 # WINDOWS_INSERT_DEF is set) and a .lib target file if
231 # they're specified explicitly.
233 test.write('SConstructBar', '''
234 env = Environment(WINDOWS_INSERT_DEF=1)
235 env2 = Environment(LIBS = [ 'foo4' ],
237 env.SharedLibrary(target = ['foo4', 'foo4.lib'], source = ['f4.c', 'foo4.def'])
238 env2.Program(target = 'progbar', source = 'progbar.c')
241 test.write('f4.c', r"""
251 test.write("foo4.def", r"""
253 DESCRIPTION "Foo4 Shared Library"
259 test.write('progbar.c', r"""
263 main(int argc, char *argv[])
267 printf("progbar.c\n");
272 test.run(arguments = '-f SConstructBar .')
274 # Make sure there is (at most) one mention each of the
275 # appropriate .def and .lib files per line.
276 for line in test.stdout().split('\n'):
277 test.fail_test(line.count('foo4.def') > 1)
278 test.fail_test(line.count('foo4.lib') > 1)
280 test.run(program = test.workpath('progbar'),
281 stdout = "f4.c\nprogbar.c\n")
287 # indent-tabs-mode:nil
289 # vim: set expandtab tabstop=4 shiftwidth=4: