added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / LINK / VersionedLib-VariantDir.py
blob4a5ac4018094d30cdc8c0d21403ce9bfc0270a85
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 """
28 Ensure that SharedLibrary builder with SHLIBVERSION set works with VariantDir.
29 """
31 import TestSCons
32 import os
33 import sys
35 import SCons.Platform
36 import SCons.Defaults
38 test = TestSCons.TestSCons()
40 env = SCons.Defaults.DefaultEnvironment()
41 platform = SCons.Platform.platform_default()
42 tool_list = SCons.Platform.DefaultToolList(platform, env)
46 test.subdir(['src'])
47 test.subdir(['src','lib'])
48 test.subdir(['src','bin'])
50 test.write(['src','lib','foo.c'], """
51 #if _WIN32
52 __declspec(dllexport)
53 #endif
54 int foo() { return 0; }
55 """)
57 test.write(['src','bin','main.c'], """
58 #if _WIN32
59 __declspec(dllimport)
60 #endif
61 int foo();
62 int main(void)
64 return foo();
66 """)
68 test.write('SConstruct', """
69 env = Environment()
70 variant = { 'variant_dir' : 'build',
71 'src_dir' : 'src',
72 'duplicate' : 0,
73 'exports' : { 'env' : env } }
74 SConscript('src/lib/SConscript', **variant)
75 SConscript('src/bin/SConscript', **variant)
76 """)
78 test.write(['src','lib','SConscript'], """
79 Import('env')
80 env.SharedLibrary('foo', 'foo.c', SHLIBVERSION = '0.1.2')
81 """ )
83 test.write(['src','bin','SConscript'], """
84 Import('env')
85 env.Program('main.c', LIBS=['foo'], LIBPATH=['../lib'])
86 """)
88 test.run(arguments = ['--tree=all'])
90 if platform == 'cygwin' or platform == 'win32':
91 # PATH is used to search for *.dll libraries on windows
92 path = os.environ.get('PATH','')
93 if path: path = path + os.pathsep
94 path = path + test.workpath('build/lib')
95 os.environ['PATH'] = path
97 if os.name == 'posix':
98 os.environ['LD_LIBRARY_PATH'] = test.workpath('build/lib')
99 if sys.platform.find('irix') != -1:
100 os.environ['LD_LIBRARYN32_PATH'] = test.workpath('build/lib')
102 test.run(program = test.workpath('build/bin/main'))
104 if 'gnulink' in tool_list:
105 # All (?) the files we expect will get created in the current directory
106 files = [
107 'libfoo.so',
108 'libfoo.so.0',
109 'libfoo.so.0.1.2',
111 obj = 'foo.os'
112 elif 'applelink' in tool_list:
113 # All (?) the files we expect will get created in the current directory
114 files = [
115 'libfoo.dylib',
116 'libfoo.0.1.2.dylib',
118 obj = 'foo.os'
119 elif 'cyglink' in tool_list:
120 # All (?) the files we expect will get created in the current directory
121 files = [
122 'cygfoo-0-1-2.dll',
123 'libfoo-0-1-2.dll.a',
124 'libfoo.dll.a',
126 obj = 'foo.os'
127 elif 'mslink' in tool_list:
128 # All (?) the files we expect will get created in the current directory
129 files = [
130 'foo.dll',
131 'foo.lib',
133 obj = 'foo.obj'
134 elif 'sunlink' in tool_list:
135 # All (?) the files we expect will get created in the current directory
136 files = [
137 'libfoo.so',
138 'libfoo.so.0',
139 'libfoo.so.0.1.2',
141 obj = 'so_foo.os'
142 else:
143 # All (?) the files we expect will get created in the current directory
144 files= [
145 'libfoo.so',
147 obj = 'foo.os'
149 test.must_exist([ 'build', 'lib', obj ])
150 for f in files:
151 test.must_exist([ 'build', 'lib', f ])
153 test.run(arguments = ['-c'])
155 test.must_not_exist([ 'build', 'lib', obj ])
156 for f in files:
157 test.must_not_exist([ 'build', 'lib', f ])
159 test.must_exist(['src', 'lib', 'foo.c'])
160 test.must_exist(['SConstruct'])
161 test.must_exist(['src', 'lib', 'SConscript'])
162 test.must_exist(['src', 'bin', 'SConscript'])
164 test.pass_test()
166 # Local Variables:
167 # tab-width:4
168 # indent-tabs-mode:nil
169 # End:
170 # vim: set expandtab tabstop=4 shiftwidth=4: