]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/searched_lib.py
c9ad5852d0a870ab1ca9976fd915f3fb7274318f
3 # Copyright 2003 Dave Abrahams
4 # Copyright 2003, 2004, 2005, 2006 Vladimir Prus
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8 # Test usage of searched-libs: one which are found via -l
9 # switch to the linker/compiler.
15 t
= BoostBuild
.Tester(use_test_config
=False)
18 # To start with, we have to prepare a library to link with.
19 t
.write("lib/jamroot.jam", "")
20 t
.write("lib/jamfile.jam", "lib test_lib : test_lib.cpp ;")
21 t
.write("lib/test_lib.cpp", """\
28 t
.run_build_system(subdir
="lib")
29 t
.expect_addition("lib/bin/$toolset/debug/test_lib.dll")
32 # Auto adjusting of suffixes does not work, since we need to
34 if ( ( os
.name
== "nt" ) or os
.uname()[0].lower().startswith("cygwin") ) and \
35 ( BoostBuild
.get_toolset() != "gcc" ):
36 t
.copy("lib/bin/$toolset/debug/test_lib.implib", "lib/test_lib.implib")
37 t
.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")
39 t
.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")
42 # Test that the simplest usage of searched library works.
43 t
.write("jamroot.jam", "")
45 t
.write("jamfile.jam", """\
48 exe main : main.cpp helper ;
49 lib helper : helper.cpp test_lib ;
50 lib test_lib : : <name>test_lib <search>lib ;
53 t
.write("main.cpp", """\
55 int main() { helper(); }
58 t
.write("helper.cpp", """\
67 t
.run_build_system(["-d2"])
68 t
.expect_addition("bin/$toolset/debug/main.exe")
69 t
.rm("bin/$toolset/debug/main.exe")
72 # Test that 'unit-test' will correctly add runtime paths to searched libraries.
73 t
.write("jamfile.jam", """\
78 project : requirements <hardcode-dll-paths>false ;
80 unit-test main : main.cpp helper ;
81 lib helper : helper.cpp test_lib ;
82 lib test_lib : : <name>test_lib <search>lib ;
86 t
.expect_addition("bin/$toolset/debug/main.passed")
87 t
.rm("bin/$toolset/debug/main.exe")
90 # Now try using searched lib from static lib. Request shared version of searched
91 # lib, since we do not have a static one handy.
92 t
.write("jamfile.jam", """\
93 exe main : main.cpp helper ;
94 lib helper : helper.cpp test_lib/<link>shared : <link>static ;
95 lib test_lib : : <name>test_lib <search>lib ;
98 t
.run_build_system(stderr
=None)
99 t
.expect_addition("bin/$toolset/debug/main.exe")
100 t
.expect_addition("bin/$toolset/debug/link-static/helper.lib")
101 t
.rm("bin/$toolset/debug/main.exe")
103 # A regression test: <library>property referring to searched-lib was being
104 # mishandled. As the result, we were putting target name to the command line!
107 # works nicely in some cases, sending output from compiler to file 'z'. This
108 # problem shows up when searched libs are in usage requirements.
109 t
.write("jamfile.jam", "exe main : main.cpp d/d2//a ;")
110 t
.write("main.cpp", """\
112 int main() { foo(); }
115 t
.write("d/d2/jamfile.jam", """\
116 lib test_lib : : <name>test_lib <search>../../lib ;
117 lib a : a.cpp : : : <library>test_lib ;
120 t
.write("d/d2/a.cpp", """\
122 __declspec(dllexport) int force_library_creation_for_a;
129 # A regression test. Searched targets were not associated with any properties.
130 # For that reason, if the same searched lib is generated with two different
131 # properties, we had an error saying they are actualized to the same Jam target
133 t
.write("jamroot.jam", "")
137 # The 'l' library will be built in two variants: 'debug' (directly requested)
138 # and 'release' (requested from 'a').
139 t
.write("jamfile.jam", """\
140 exe a : a.cpp l/<variant>release ;
141 lib l : : <name>l_d <variant>debug ;
142 lib l : : <name>l_r <variant>release ;
145 t
.run_build_system(["-n"])
148 # A regression test. Two virtual target with the same properties were created
149 # for 'l' target, which caused and error to be reported when actualizing
150 # targets. The final error is correct, but we should not create two duplicated
151 # targets. Thanks to Andre Hentz for finding this bug.
152 t
.write("jamroot.jam", "")
154 t
.write("jamfile.jam", """\
155 project a : requirements <runtime-link>static ;
156 static-lib a : a.cpp l ;
157 lib l : : <name>l_f ;
160 t
.run_build_system(["-n"])
163 # Make sure plain "lib foobar ; " works.
164 t
.write("jamfile.jam", """\
165 exe a : a.cpp foobar ;
169 t
.run_build_system(["-n", "-d2"])
170 t
.fail_test(string
.find(t
.stdout(), "foobar") == -1)
173 # Make sure plain "lib foo bar ; " works.
174 t
.write("jamfile.jam", """\
175 exe a : a.cpp foo bar ;
179 t
.run_build_system(["-n", "-d2"])
180 t
.fail_test(string
.find(t
.stdout(), "foo") == -1)
181 t
.fail_test(string
.find(t
.stdout(), "bar") == -1)