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.
25 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
31 test
= TestSCons
.TestSCons()
33 e
= test
.Environment()
34 fooflags
= e
['SHCFLAGS'] + ' -DFOO'
35 barflags
= e
['SHCFLAGS'] + ' -DBAR'
37 if os
.name
== 'posix':
38 os
.environ
['LD_LIBRARY_PATH'] = '.'
39 if sys
.platform
.find('irix') > -1:
40 os
.environ
['LD_LIBRARYN32_PATH'] = '.'
42 test
.write('SConstruct', f
"""
43 DefaultEnvironment(tools=[])
44 foo = Environment(SHCFLAGS = '{fooflags}', WINDOWS_INSERT_DEF=1)
45 bar = Environment(SHCFLAGS = '{barflags}', 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)
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', f
"""
111 DefaultEnvironment(tools=[])
112 bar = Environment(SHCFLAGS = '{barflags}', WINDOWS_INSERT_DEF=1)
114 foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c')
115 bar.SharedLibrary(target = 'foo', source = foo_obj)
117 bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c')
118 bar.SharedLibrary(target = 'bar', source = bar_obj)
120 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
121 foomain_obj = barMain.Object(target='foomain', source='main.c')
122 barmain_obj = barMain.Object(target='barmain', source='main.c')
123 barMain.Program(target='barprog', source=foomain_obj)
124 barMain.Program(target='fooprog', source=barmain_obj)
127 test
.run(arguments
= '.')
129 test
.run(program
= test
.workpath('fooprog'), stdout
= "prog.c: BAR\n")
130 test
.run(program
= test
.workpath('barprog'), stdout
= "prog.c: BAR\n")
136 # indent-tabs-mode:nil
138 # vim: set expandtab tabstop=4 shiftwidth=4: