]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/library_order.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / library_order.py
1 #!/usr/bin/python
2
3 # Copyright 2004 Vladimir Prus
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7 # Test that on compilers sensitive to library order on linker's command line,
8 # we generate the correct order.
9
10 import BoostBuild
11
12
13 t = BoostBuild.Tester(use_test_config=False)
14
15 t.write("main.cpp", """\
16 void a();
17 int main() { a(); }
18 """)
19
20 t.write("a.cpp", """\
21 void b();
22 void a() { b(); }
23 """)
24
25 t.write("b.cpp", """\
26 void c();
27 void b() { c(); }
28 """)
29
30 t.write("c.cpp", """\
31 void d();
32 void c() { d(); }
33 """)
34
35 t.write("d.cpp", """\
36 void d() {}
37 """)
38
39 # The order of libraries in 'main' is crafted so that we get an error unless we
40 # do something about the order ourselves.
41 t.write("jamroot.jam", """\
42 exe main : main.cpp libd libc libb liba ;
43 lib libd : d.cpp ;
44 lib libc : c.cpp : <link>static <use>libd ;
45 lib libb : b.cpp : <use>libc ;
46 lib liba : a.cpp : <use>libb ;
47 """)
48
49 t.run_build_system(["-d2"])
50 t.expect_addition("bin/$toolset/debug*/main.exe")
51
52
53 # Test the order between searched libraries.
54 t.write("jamroot.jam", """\
55 exe main : main.cpp png z ;
56 lib png : z : <name>png ;
57 lib z : : <name>zzz ;
58 """)
59
60 t.run_build_system(["-a", "-n", "-d+2"])
61 t.fail_test(t.stdout().find("png") > t.stdout().find("zzz"))
62
63 t.write("jamroot.jam", """\
64 exe main : main.cpp png z ;
65 lib png : : <name>png ;
66 lib z : png : <name>zzz ;
67 """)
68
69 t.run_build_system(["-a", "-n", "-d+2"])
70 t.fail_test(t.stdout().find("png") < t.stdout().find("zzz"))
71
72
73 # Test the order between prebuilt libraries.
74 t.write("first.a", "")
75 t.write("second.a", "")
76 t.write("jamroot.jam", """\
77 exe main : main.cpp first second ;
78 lib first : second : <file>first.a ;
79 lib second : : <file>second.a ;
80 """)
81
82 t.run_build_system(["-a", "-n", "-d+2"])
83 t.fail_test(t.stdout().find("first") > t.stdout().find("second"))
84
85 t.write("jamroot.jam", """
86 exe main : main.cpp first second ;
87 lib first : : <file>first.a ;
88 lib second : first : <file>second.a ;
89 """)
90
91 t.run_build_system(["-a", "-n", "-d+2"])
92 t.fail_test(t.stdout().find("first") < t.stdout().find("second"))
93
94 t.cleanup()