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.
32 env
= SCons
.Defaults
.DefaultEnvironment()
33 platform
= SCons
.Platform
.platform_default()
34 tool_list
= SCons
.Platform
.DefaultToolList(platform
, env
)
36 if 'gnulink' in tool_list
:
40 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ],
41 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
42 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
46 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ],
47 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
48 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
51 'libversion' : '2.5.4',
52 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ],
53 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
54 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
57 'libversion' : '2.5.4.7.8',
58 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ],
59 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
60 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
63 'libversion' : 'aabf114f',
64 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ],
65 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
66 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
69 'libversion' : '2.dfffa11',
70 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ],
71 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
72 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
75 elif 'applelink' in tool_list
:
76 # All (?) the files we expect will get created in the current directory
79 'libversion' : '2.5.4',
80 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ],
81 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ],
85 elif 'cyglink' in tool_list
:
89 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ],
90 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ],
91 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ],
95 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ],
96 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ],
97 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ],
100 'libversion' : '2.5.4',
101 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ],
102 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ],
103 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ],
106 'libversion' : '2.5.4.7.8',
107 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ],
108 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ],
109 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ],
112 'libversion' : 'aabf114f',
113 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ],
114 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ],
115 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ],
118 'libversion' : '2.dfffa11',
119 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ],
120 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ],
121 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ],
124 elif 'mslink' in tool_list
:
127 'libversion' : '2.5.4',
128 'files' : [ 'test.dll', 'test.lib', 'test.obj' ],
129 'instfiles' : [ 'test.dll', 'test.lib' ],
133 elif 'sunlink' in tool_list
:
137 'files' : [ 'libtest.so', 'libtest.so.2', 'test.pic.o' ],
138 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
139 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
142 'libversion' : '2.5',
143 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.pic.o' ],
144 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
145 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
148 'libversion' : '2.5.4',
149 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.pic.o' ],
150 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
151 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
154 'libversion' : '2.5.4.7.8',
155 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.pic.o' ],
156 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
157 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
160 'libversion' : 'aabf114f',
161 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.pic.o' ],
162 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
163 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
166 'libversion' : '2.dfffa11',
167 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.pic.o' ],
168 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
169 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
175 'libversion' : '2.5.4',
176 'files' : [ 'libtest.so', 'test.os' ],
183 __declspec(dllexport)
185 int testlib(int n) { return n+1 ; }
190 __declspec(dllexport)
192 int testlib(int n) { return n+11 ; }
197 __declspec(dllimport)
201 int main(int argc, char **argv)
206 printf("results: testlib(2) = %d\\n",itest) ;
213 test
= TestSCons
.TestSCons()
215 libversion
= t
['libversion']
217 symlinks
= t
['symlinks']
218 instfiles
= t
['instfiles']
220 test
.write('SConstruct', """\
221 DefaultEnvironment(tools=[])
223 objs = env.SharedObject('test.c')
224 mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s')
225 env.Program('testapp1.c', LIBS = mylib, LIBPATH='.')
226 env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.')
227 instnode = env.InstallVersionedLib("#/installtest",mylib)
228 env.Default(instnode)
230 # Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment
231 # Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError.
232 instnode = InstallVersionedLib("defaultenv-installtest",mylib)
237 test
.write('test.c', test_c_src
)
238 test
.write('testapp1.c', testapp_c_src
)
239 test
.write('testapp2.c', testapp_c_src
)
241 test
.run(arguments
= ['--tree=all'])
244 test
.must_exist([ f
])
246 test
.must_exist(['installtest', f
])
247 test
.must_exist(['defaultenv-installtest', f
])
250 for (linkname
,expected
) in symlinks
:
252 endpoint
= os
.readlink(linkname
)
253 except OSError as err
:
254 print("%s (expected symlink %r -> %r)" % (err
, linkname
, expected
))
255 wrong_symlinks
.append(linkname
)
257 if endpoint
!= expected
:
258 print("Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname
, endpoint
, linkname
, expected
))
259 wrong_symlinks
.append(linkname
)
262 test
.fail_test(wrong_symlinks
)
264 # modify test.c and make sure it can recompile when links already exist
265 test
.write('test.c', test_c_src2
)
269 test
.run(arguments
= ['-c'])
272 test
.must_not_exist([ f
])
275 test
.must_not_exist(['installtest', f
])
276 test
.must_not_exist(['defaultenv-installtest', f
])
282 # indent-tabs-mode:nil
284 # vim: set expandtab tabstop=4 shiftwidth=4: