Updates to PR 4374 from mwichmann to correct config file hash changes
[scons.git] / test / CC / SHCCFLAGS.py
blob71ed1c0f98da38a4dae3e9fcd9e39e5b4d35b3c1
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 import sys
28 import TestSCons
29 import os
31 test = TestSCons.TestSCons()
33 e = test.Environment()
34 fooflags = e['SHCCFLAGS'] + ' -DFOO'
35 barflags = e['SHCCFLAGS'] + ' -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', """
43 DefaultEnvironment(tools=[])
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"""
63 LIBRARY "foo"
64 DESCRIPTION "Foo Shared Library"
66 EXPORTS
67 doIt
68 """)
70 test.write('bar.def', r"""
71 LIBRARY "bar"
72 DESCRIPTION "Bar Shared Library"
74 EXPORTS
75 doIt
76 """)
78 test.write('prog.c', r"""
79 #include <stdio.h>
81 void
82 doIt()
84 #ifdef FOO
85 printf("prog.c: FOO\n");
86 #endif
87 #ifdef BAR
88 printf("prog.c: BAR\n");
89 #endif
91 """)
93 test.write('main.c', r"""
95 void doIt();
97 int
98 main(int argc, char* argv[])
100 doIt();
101 return 0;
103 """)
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)
124 """ % barflags)
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")
131 test.pass_test()
133 # Local Variables:
134 # tab-width:4
135 # indent-tabs-mode:nil
136 # End:
137 # vim: set expandtab tabstop=4 shiftwidth=4: