]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/library_chain.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / library_chain.py
CommitLineData
7c673cae
FG
1#!/usr/bin/python
2
3# Copyright 2003, 2004, 2005, 2006 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 a chain of libraries works ok, no matter if we use static or shared
8# linking.
9
10import BoostBuild
11import os
12import string
13
14t = BoostBuild.Tester(use_test_config=False)
15
16# Stage the binary, so that it will be relinked without hardcode-dll-paths.
17# That will check that we pass correct -rpath-link, even if not passing -rpath.
18t.write("jamfile.jam", """\
19stage dist : main ;
20exe main : main.cpp b ;
21""")
22
23t.write("main.cpp", """\
24void foo();
25int main() { foo(); }
26""")
27
28t.write("jamroot.jam", "")
29
30t.write("a/a.cpp", """\
31void
32#if defined(_WIN32)
33__declspec(dllexport)
34#endif
35gee() {}
36void
37#if defined(_WIN32)
38__declspec(dllexport)
39#endif
40geek() {}
41""")
42
43t.write("a/jamfile.jam", "lib a : a.cpp ;")
44
45t.write("b/b.cpp", """\
46void geek();
47void
48#if defined(_WIN32)
49__declspec(dllexport)
50#endif
51foo() { geek(); }
52""")
53
54t.write("b/jamfile.jam", "lib b : b.cpp ../a//a ;")
55
56t.run_build_system(["-d2"], stderr=None)
b32b8144 57t.expect_addition("bin/$toolset/debug*/main.exe")
7c673cae
FG
58t.rm(["bin", "a/bin", "b/bin"])
59
60t.run_build_system(["link=static"])
b32b8144 61t.expect_addition("bin/$toolset/debug/link-static*/main.exe")
7c673cae
FG
62t.rm(["bin", "a/bin", "b/bin"])
63
64
65# Check that <library> works for static linking.
66t.write("b/jamfile.jam", "lib b : b.cpp : <library>../a//a ;")
67
68t.run_build_system(["link=static"])
b32b8144 69t.expect_addition("bin/$toolset/debug/link-static*/main.exe")
7c673cae
FG
70
71t.rm(["bin", "a/bin", "b/bin"])
72
73t.write("b/jamfile.jam", "lib b : b.cpp ../a//a/<link>shared : <link>static ;")
74
75t.run_build_system()
b32b8144 76t.expect_addition("bin/$toolset/debug*/main.exe")
7c673cae
FG
77
78t.rm(["bin", "a/bin", "b/bin"])
79
80
81# Test that putting a library in sources of a searched library works.
82t.write("jamfile.jam", """\
83exe main : main.cpp png ;
84lib png : z : <name>png ;
85lib z : : <name>zzz ;
86""")
87
88t.run_build_system(["-a", "-d+2"], status=None, stderr=None)
89# Try to find the "zzz" string either in response file (for Windows compilers),
90# or in the standard output.
b32b8144 91rsp = t.adjust_names("bin/$toolset/debug*/main.exe.rsp")[0]
7c673cae
FG
92if os.path.exists(rsp) and ( string.find(open(rsp).read(), "zzz") != -1 ):
93 pass
94elif string.find(t.stdout(), "zzz") != -1:
95 pass
96else:
97 t.fail_test(1)
98
99# Test main -> libb -> liba chain in the case where liba is a file and not a
100# Boost.Build target.
101t.rm(".")
102
103t.write("jamroot.jam", "")
104t.write("a/jamfile.jam", """\
105lib a : a.cpp ;
106install dist : a ;
107""")
108
109t.write("a/a.cpp", """\
110#if defined(_WIN32)
111__declspec(dllexport)
112#endif
113void a() {}
114""")
115
116t.run_build_system(subdir="a")
117t.expect_addition("a/dist/a.dll")
118
119if ( os.name == 'nt' or os.uname()[0].lower().startswith('cygwin') ) and \
120 BoostBuild.get_toolset() != 'gcc':
121 # This is a Windows import library -- we know the exact name.
122 file = "a/dist/a.lib"
123else:
124 file = t.adjust_names("a/dist/a.dll")[0]
125
126t.write("b/jamfile.jam", "lib b : b.cpp ../%s ;" % file)
127
128t.write("b/b.cpp", """\
129#if defined(_WIN32)
130__declspec(dllimport)
131#endif
132void a();
133#if defined(_WIN32)
134__declspec(dllexport)
135#endif
136void b() { a(); }
137""")
138
139t.write("jamroot.jam", "exe main : main.cpp b//b ;")
140
141t.write("main.cpp", """\
142#if defined(_WIN32)
143__declspec(dllimport)
144#endif
145void b();
146int main() { b(); }
147""")
148
149t.run_build_system()
b32b8144 150t.expect_addition("bin/$toolset/debug*/main.exe")
7c673cae
FG
151
152t.cleanup()