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.
33 foo_c_src
= "void foo() {}\n"
35 env
= SCons
.Defaults
.DefaultEnvironment()
36 platform
= SCons
.Platform
.platform_default()
37 tool_list
= SCons
.Platform
.DefaultToolList(platform
, env
)
39 test
= TestSCons
.TestSCons()
40 if 'gnulink' in tool_list
:
41 versionflags
= r
".+ -Wl,-soname=libfoo.so.1( .+)+"
42 soname
= 'libfoo.so.4'
43 sonameVersionFlags
= r
".+ -Wl,-soname=%s( .+)+" % soname
45 elif 'sunlink' in tool_list
:
46 versionflags
= r
".+ -h libfoo.so.1( .+)+"
47 soname
= 'libfoo.so.4'
48 sonameVersionFlags
= r
".+ -h %s( .+)+" % soname
49 elif 'applelink' in tool_list
:
50 versionflags
= r
".+ -Wl,-current_version,1.2.3( .+)+"
51 soname
= 'libfoo.4.dylib'
52 sonameVersionFlags
= r
".+ -Wl,-compatibility_version,1.2.0(.+)+"
54 test
.skip_test('No testable linkers found, skipping the test\n')
56 # stdout must not contain SHLIBVERSIONFLAGS if there is no SHLIBVERSION provided
57 test
.write('foo.c', foo_c_src
)
58 test
.write('SConstruct', "SharedLibrary('foo','foo.c')\n")
60 test
.fail_test(test
.match_re_dotall(test
.stdout(), versionflags
))
61 test
.run(arguments
=['-c'])
63 # stdout must contain SHLIBVERSIONFLAGS if there is SHLIBVERSION provided
64 test
= TestSCons
.TestSCons()
65 test
.write('foo.c', foo_c_src
)
66 test
.write('SConstruct', "SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3')\n")
67 test
.run(stdout
=versionflags
, match
=TestSCons
.match_re_dotall
)
68 test
.run(arguments
=['-c'])
70 # stdout must contain SONAME if there is SONAME provided
71 test
= TestSCons
.TestSCons()
72 test
.write('foo.c', foo_c_src
)
73 test
.write('SConstruct', """
74 SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3',SONAME='%s')
76 test
.run(stdout
=sonameVersionFlags
, match
=TestSCons
.match_re_dotall
)
77 test
.must_exist(test
.workpath(soname
))
78 test
.run(arguments
=['-c'])
80 # stdout must contain SOVERSION if there is SOVERSION provided
81 test
= TestSCons
.TestSCons()
82 test
.write('foo.c', foo_c_src
)
83 test
.write('SConstruct', """
84 SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3',SOVERSION='4')
86 test
.run(stdout
=sonameVersionFlags
, match
=TestSCons
.match_re_dotall
)
87 test
.must_exist(test
.workpath(soname
))
88 test
.run(arguments
=['-c'])
90 # test if both SONAME and SOVERSION are used
91 test
= TestSCons
.TestSCons()
92 test
.write('foo.c', foo_c_src
)
93 test
.write('SConstruct', """
94 SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3',SONAME='%s',SOVERSION='4')
96 test
.run(status
=2, stderr
=None)
97 test
.must_contain_all_lines(test
.stderr(), ['Ambiguous library .so naming'])
103 # indent-tabs-mode:nil
105 # vim: set expandtab tabstop=4 shiftwidth=4: