Small docstring update for vars.Add
[scons.git] / test / LINK / VersionedLib-j2.py
blob8f84a1a18eac550dc98fe35d3ef9c2e3a7c754cc
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 """
27 Ensure that SharedLibrary builder works with SHLIBVERSION and -j2.
28 This is regression test for:
29 https://article.gmane.org/gmane.comp.programming.tools.scons.user/27049
30 (historical - dead link)
31 """
33 import TestSCons
34 import os
35 import sys
37 import SCons.Platform
38 import SCons.Defaults
40 test = TestSCons.TestSCons()
42 test.write('foo.c', """
43 #if _WIN32
44 __declspec(dllexport)
45 #endif
46 int foo() { return 0; }
47 """)
50 test.write('main.c', """
51 #if _WIN32
52 __declspec(dllimport)
53 #endif
54 int foo();
55 int main(void) { return foo(); }
56 """)
58 test.write('SConstruct', """
59 env = Environment()
60 env.AppendUnique(LIBPATH = ['.'])
61 env.Program('main.c', LIBS = ['foo'])
62 env.SharedLibrary('foo', 'foo.c', SHLIBVERSION = '0.1.2')
63 """)
65 test.run(arguments = ['-j 2', '--tree=all'])
67 env = SCons.Defaults.DefaultEnvironment()
68 platform = SCons.Platform.platform_default()
69 tool_list = SCons.Platform.DefaultToolList(platform, env)
71 if platform == 'cygwin':
72 # PATH is used to search for *.dll librarier (cygfoo-0-2-1.dll in our case)
73 path = os.environ.get('PATH','')
74 if path: path = path + os.pathsep
75 path = path + test.workpath('.')
76 os.environ['PATH'] = path
78 if os.name == 'posix':
79 os.environ['LD_LIBRARY_PATH'] = test.workpath('.')
80 if sys.platform.find('irix') != -1:
81 os.environ['LD_LIBRARYN32_PATH'] = test.workpath('.')
83 test.run(program = test.workpath('main'))
85 test.run(arguments = ['-c'])
87 platform = SCons.Platform.platform_default()
89 if 'gnulink' in tool_list:
90 # All (?) the files we expect will get created in the current directory
91 files = [
92 'libfoo.so',
93 'libfoo.so.0',
94 'libfoo.so.0.1.2',
95 'foo.os',
97 elif 'applelink' in tool_list:
98 # All (?) the files we expect will get created in the current directory
99 files = [
100 'libfoo.dylib',
101 'libfoo.0.1.2.dylib',
102 'foo.os',
104 elif 'cyglink' in tool_list:
105 # All (?) the files we expect will get created in the current directory
106 files = [
107 'cygfoo-0-1-2.dll',
108 'libfoo-0-1-2.dll.a',
109 'libfoo.dll.a',
110 'foo.os',
112 elif 'mslink' in tool_list:
113 # All (?) the files we expect will get created in the current directory
114 files = [
115 'foo.dll',
116 'foo.lib',
117 'foo.obj',
119 elif 'sunlink' in tool_list:
120 # All (?) the files we expect will get created in the current directory
121 files = [
122 'libfoo.so',
123 'libfoo.so.0',
124 'libfoo.so.0.1.2',
125 'so_foo.os',
127 else:
128 # All (?) the files we expect will get created in the current directory
129 files= [
130 'libfoo.so',
131 'foo.os']
133 for f in files:
134 test.must_not_exist([ f])
136 test.must_exist(['main.c'])
137 test.must_exist(['foo.c'])
138 test.must_exist(['SConstruct'])
140 test.pass_test()
142 # Local Variables:
143 # tab-width:4
144 # indent-tabs-mode:nil
145 # End:
146 # vim: set expandtab tabstop=4 shiftwidth=4: