Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/test/library_chain.py @ 32

Last change on this file since 32 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.3 KB
Line 
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 work ok, not matter if we use static or
8#  shared linking.
9from BoostBuild import Tester, List, get_toolset
10import string
11import os
12
13t = Tester()
14
15t.write("Jamfile", """
16# Stage the binary, so that it will be relinked
17# without hardcode-dll-paths. That will chech that
18# we pass correct -rpath-link, even if not passing
19# -rpath.
20stage dist : main ;
21exe main : main.cpp b ;
22""")
23
24t.write("main.cpp", """
25void foo();
26
27int main() { foo(); return 0; }
28
29""")
30
31t.write("project-root.jam", """
32""")
33
34t.write("a/a.cpp", """
35void
36#if defined(_WIN32)
37__declspec(dllexport)
38#endif
39gee() {}
40void
41#if defined(_WIN32)
42__declspec(dllexport)
43#endif
44geek() {}
45""")
46
47t.write("a/Jamfile", """
48lib a : a.cpp ;
49""")
50
51t.write("b/b.cpp", """
52void geek();
53
54void
55#if defined(_WIN32)
56__declspec(dllexport)
57#endif
58foo() { geek(); }
59
60""")
61
62t.write("b/Jamfile", """
63lib b : b.cpp ../a//a ;
64""")
65
66t.run_build_system(stderr=None)
67t.expect_addition("bin/$toolset/debug/main.exe")
68t.rm(["bin", "a/bin", "b/bin"])
69
70t.run_build_system("link=static")
71t.expect_addition("bin/$toolset/debug/link-static/main.exe")
72t.rm(["bin", "a/bin", "b/bin"])
73
74# Check that <library> works for static linking.
75
76t.write("b/Jamfile", """
77lib b : b.cpp : <library>../a//a ;
78""")
79t.run_build_system("link=static")
80t.expect_addition("bin/$toolset/debug/link-static/main.exe")
81
82t.rm(["bin", "a/bin", "b/bin"])
83t.write("b/Jamfile", """
84lib b : b.cpp ../a//a/<link>shared : <link>static ;
85""")
86
87t.run_build_system()
88t.expect_addition("bin/$toolset/debug/main.exe")
89t.rm(["bin", "a/bin", "b/bin"])
90
91# Test that putting library in sources of a searched library
92# works.
93t.write("Jamfile", """
94exe main : main.cpp png ;
95lib png : z : <name>png ;
96lib z : : <name>zzz ;
97""")
98t.run_build_system("-a -d+2", status=None, stderr=None)
99# Try to find the "zzz" string either in response file
100# (for Windows compilers), or in standard output.
101rsp = t.adjust_names("bin/$toolset/debug/main.exe.rsp")[0]
102if os.path.exists(rsp) and string.find(open(rsp).read(), "zzz") != -1:
103    pass
104elif string.find(t.stdout(), "zzz") != -1:
105    pass
106else:
107    t.fail_test(1)
108
109#
110# Test main -> libb -> liba chain
111# in the case where liba is a file, not a Boost.Build target.
112#
113t.rm(".")
114t.write("Jamroot", "")
115t.write("a/Jamfile", """
116lib a : a.cpp ;
117install dist : a ;
118""")
119t.write("a/a.cpp", """
120#if defined(_WIN32)
121__declspec(dllexport)
122#endif
123void a() {}
124""")
125t.run_build_system(subdir="a")
126t.expect_addition("a/dist/a.dll")
127
128if (os.name == 'nt' or os.uname()[0].lower().startswith('cygwin')) and get_toolset() != 'gcc':
129    file = t.adjust_names(["a/dist/a.lib"])[0]
130else:
131    file = t.adjust_names(["a/dist/a.dll"])[0]
132
133t.write("b/Jamfile", """
134lib b : b.cpp ../%s ;
135""" % file)
136t.write("b/b.cpp", """
137#if defined(_WIN32)
138__declspec(dllimport)
139#endif
140void a();
141
142#if defined(_WIN32)
143__declspec(dllexport)
144#endif
145void b() { a(); }
146""")
147
148t.write("Jamroot", """
149exe main : main.cpp b//b ;
150""")
151t.write("main.cpp", """
152#if defined(_WIN32)
153__declspec(dllimport)
154#endif
155void b();
156int main() { b(); }
157""")
158
159t.run_build_system()
160t.expect_addition("bin/$toolset/debug/main.exe")
161
162
163
164t.cleanup()
Note: See TracBrowser for help on using the repository browser.