added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / CC / SHCCFLAGS.py
bloba923f90010328a4e50925e1c8cd06ef00d8f9cb9
1 #!/usr/bin/env python
3 # MIT License
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.
26 import sys
27 import TestSCons
28 import os
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"""
62 LIBRARY "foo"
63 DESCRIPTION "Foo Shared Library"
65 EXPORTS
66 doIt
67 """)
69 test.write('bar.def', r"""
70 LIBRARY "bar"
71 DESCRIPTION "Bar Shared Library"
73 EXPORTS
74 doIt
75 """)
77 test.write('prog.c', r"""
78 #include <stdio.h>
80 void
81 doIt()
83 #ifdef FOO
84 printf("prog.c: FOO\n");
85 #endif
86 #ifdef BAR
87 printf("prog.c: BAR\n");
88 #endif
90 """)
92 test.write('main.c', r"""
94 void doIt();
96 int
97 main(int argc, char* argv[])
99 doIt();
100 return 0;
102 """)
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)
123 """ % barflags)
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")
130 test.pass_test()
132 # Local Variables:
133 # tab-width:4
134 # indent-tabs-mode:nil
135 # End:
136 # vim: set expandtab tabstop=4 shiftwidth=4: