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 e = test.Environment()
35 fooflags = e['SHCCFLAGS'] + ' -DFOO'
36 barflags = e['SHCCFLAGS'] + ' -DBAR'
38 if os.name == 'posix':
39 os.environ['LD_LIBRARY_PATH'] = '.'
40 if string.find(sys.platform, 'irix') > -1:
41 os.environ['LD_LIBRARYN32_PATH'] = '.'
43 test.write('SConstruct', """
44 foo = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
45 bar = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
47 foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c')
48 foo.SharedLibrary(target = 'foo', source = foo_obj)
50 bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
51 bar.SharedLibrary(target = 'bar', source = bar_obj)
53 fooMain = foo.Clone(LIBS='foo', LIBPATH='.')
54 foomain_obj = fooMain.Object(target='foomain', source='main.c')
55 fooMain.Program(target='fooprog', source=foomain_obj)
57 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
58 barmain_obj = barMain.Object(target='barmain', source='main.c')
59 barMain.Program(target='barprog', source=barmain_obj)
60 """ % (fooflags, barflags))
62 test.write('foo.def', r"""
64 DESCRIPTION "Foo Shared Library"
70 test.write('bar.def', r"""
72 DESCRIPTION "Bar Shared Library"
78 test.write('prog.c', r"""
85 printf("prog.c: FOO\n");
88 printf("prog.c: BAR\n");
93 test.write('main.c', r"""
98 main(int argc, char* argv[])
105 test.run(arguments = '.')
107 test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n")
108 test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")
110 test.write('SConstruct', """
111 bar = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
113 foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c')
114 bar.SharedLibrary(target = 'foo', source = foo_obj)
116 bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
117 bar.SharedLibrary(target = 'bar', source = bar_obj)
119 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
120 foomain_obj = barMain.Object(target='foomain', source='main.c')
121 barmain_obj = barMain.Object(target='barmain', source='main.c')
122 barMain.Program(target='barprog', source=foomain_obj)
123 barMain.Program(target='fooprog', source=barmain_obj)
126 test.run(arguments = '.')
128 test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n")
129 test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")