5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 test
= TestSCons
.TestSCons()
32 e
= test
.Environment()
33 fooflags
= e
['SHCCFLAGS'] + ' -DFOO'
34 barflags
= e
['SHCCFLAGS'] + ' -DBAR'
36 if os
.name
== 'posix':
37 os
.environ
['LD_LIBRARY_PATH'] = '.'
38 if sys
.platform
.find('irix') > -1:
39 os
.environ
['LD_LIBRARYN32_PATH'] = '.'
41 test
.write('SConstruct', """
42 DefaultEnvironment(tools=[])
43 foo = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
44 bar = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
46 foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c')
47 foo.SharedLibrary(target = 'foo', source = foo_obj)
49 bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
50 bar.SharedLibrary(target = 'bar', source = bar_obj)
52 fooMain = foo.Clone(LIBS='foo', LIBPATH='.')
53 foomain_obj = fooMain.Object(target='foomain', source='main.c')
54 fooMain.Program(target='fooprog', source=foomain_obj)
56 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
57 barmain_obj = barMain.Object(target='barmain', source='main.c')
58 barMain.Program(target='barprog', source=barmain_obj)
59 """ % (fooflags
, barflags
))
61 test
.write('foo.def', r
"""
63 DESCRIPTION "Foo Shared Library"
69 test
.write('bar.def', r
"""
71 DESCRIPTION "Bar Shared Library"
77 test
.write('prog.c', r
"""
84 printf("prog.c: FOO\n");
87 printf("prog.c: BAR\n");
92 test
.write('main.c', r
"""
97 main(int argc, char* argv[])
104 test
.run(arguments
= '.')
106 test
.run(program
= test
.workpath('fooprog'), stdout
= "prog.c: FOO\n")
107 test
.run(program
= test
.workpath('barprog'), stdout
= "prog.c: BAR\n")
109 test
.write('SConstruct', """
110 bar = Environment(SHCCFLAGS = '%s', WINDOWS_INSERT_DEF=1)
112 foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c')
113 bar.SharedLibrary(target = 'foo', source = foo_obj)
115 bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
116 bar.SharedLibrary(target = 'bar', source = bar_obj)
118 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
119 foomain_obj = barMain.Object(target='foomain', source='main.c')
120 barmain_obj = barMain.Object(target='barmain', source='main.c')
121 barMain.Program(target='barprog', source=foomain_obj)
122 barMain.Program(target='fooprog', source=barmain_obj)
125 test
.run(arguments
= '.')
127 test
.run(program
= test
.workpath('fooprog'), stdout
= "prog.c: BAR\n")
128 test
.run(program
= test
.workpath('barprog'), stdout
= "prog.c: BAR\n")
134 # indent-tabs-mode:nil
136 # vim: set expandtab tabstop=4 shiftwidth=4: