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__"
28 Verify that $CXXFLAGS settings are used to build both static
29 and shared object files.
39 if os
.name
== 'posix':
40 os
.environ
['LD_LIBRARY_PATH'] = '.'
41 if sys
.platform
.find('irix') > -1:
42 os
.environ
['LD_LIBRARYN32_PATH'] = '.'
44 test
= TestSCons
.TestSCons()
46 e
= test
.Environment()
48 test
.write('SConstruct', """
49 foo = Environment(WINDOWS_INSERT_DEF=1)
50 foo.Append(CXXFLAGS = '-DFOO')
51 bar = Environment(WINDOWS_INSERT_DEF=1)
52 bar.Append(CXXFLAGS = '-DBAR')
53 foo_obj = foo.SharedObject(target = 'fooshared%(_obj)s', source = 'doIt.cpp')
54 bar_obj = bar.SharedObject(target = 'barshared%(_obj)s', source = 'doIt.cpp')
55 foo.SharedLibrary(target = 'foo', source = foo_obj)
56 bar.SharedLibrary(target = 'bar', source = bar_obj)
58 fooMain = foo.Clone(LIBS='foo', LIBPATH='.')
59 foo_obj = fooMain.Object(target='foomain', source='main.c')
60 fooMain.Program(target='fooprog', source=foo_obj)
62 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
63 bar_obj = barMain.Object(target='barmain', source='main.c')
64 barMain.Program(target='barprog', source=bar_obj)
66 foo_obj = foo.Object(target = 'foostatic', source = 'prog.cpp')
67 bar_obj = bar.Object(target = 'barstatic', source = 'prog.cpp')
68 foo.Program(target = 'foo', source = foo_obj)
69 bar.Program(target = 'bar', source = bar_obj)
72 test
.write('foo.def', r
"""
74 DESCRIPTION "Foo Shared Library"
80 test
.write('bar.def', r
"""
82 DESCRIPTION "Bar Shared Library"
88 test
.write('doIt.cpp', r
"""
95 printf("doIt.cpp: FOO\n");
98 printf("doIt.cpp: BAR\n");
103 test
.write('main.c', r
"""
108 main(int argc, char* argv[])
115 test
.write('prog.cpp', r
"""
120 main(int argc, char *argv[])
122 argv[argc++] = (char *)"--";
124 printf("prog.c: FOO\n");
127 printf("prog.c: BAR\n");
133 test
.run(arguments
= '.')
135 test
.run(program
= test
.workpath('fooprog'), stdout
= "doIt.cpp: FOO\n")
136 test
.run(program
= test
.workpath('barprog'), stdout
= "doIt.cpp: BAR\n")
137 test
.run(program
= test
.workpath('foo'), stdout
= "prog.c: FOO\n")
138 test
.run(program
= test
.workpath('bar'), stdout
= "prog.c: BAR\n")
142 test
.write('SConstruct', """
143 bar = Environment(WINDOWS_INSERT_DEF=1)
144 bar.Append(CXXFLAGS = '-DBAR')
145 foo_obj = bar.SharedObject(target = 'foo%(_obj)s', source = 'doIt.cpp')
146 bar_obj = bar.SharedObject(target = 'bar%(_obj)s', source = 'doIt.cpp')
147 bar.SharedLibrary(target = 'foo', source = foo_obj)
148 bar.SharedLibrary(target = 'bar', source = bar_obj)
150 barMain = bar.Clone(LIBS='bar', LIBPATH='.')
151 foo_obj = barMain.Object(target='foomain', source='main.c')
152 bar_obj = barMain.Object(target='barmain', source='main.c')
153 barMain.Program(target='barprog', source=foo_obj)
154 barMain.Program(target='fooprog', source=bar_obj)
157 test
.run(arguments
= '.')
159 test
.run(program
= test
.workpath('fooprog'), stdout
= "doIt.cpp: BAR\n")
160 test
.run(program
= test
.workpath('barprog'), stdout
= "doIt.cpp: BAR\n")
168 # indent-tabs-mode:nil
170 # vim: set expandtab tabstop=4 shiftwidth=4: