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