1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and |
---|
4 | # distribute this software is granted provided this copyright notice appears in |
---|
5 | # all copies. This software is provided "as is" without express or implied |
---|
6 | # warranty, and with no claim as to its suitability for any purpose. |
---|
7 | |
---|
8 | # Test that a chain of libraries work ok, not matter if we use static or |
---|
9 | # shared linking. |
---|
10 | from BoostBuild import Tester, List |
---|
11 | import string |
---|
12 | |
---|
13 | t = Tester() |
---|
14 | |
---|
15 | t.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. |
---|
20 | stage dist : main ; |
---|
21 | exe main : main.cpp b ; |
---|
22 | """) |
---|
23 | |
---|
24 | t.write("main.cpp", """ |
---|
25 | void foo(); |
---|
26 | |
---|
27 | int main() { foo(); return 0; } |
---|
28 | |
---|
29 | """) |
---|
30 | |
---|
31 | t.write("project-root.jam", """ |
---|
32 | """) |
---|
33 | |
---|
34 | t.write("a/a.cpp", """ |
---|
35 | void |
---|
36 | #if defined(_WIN32) |
---|
37 | __declspec(dllexport) |
---|
38 | #endif |
---|
39 | gee() {} |
---|
40 | void |
---|
41 | #if defined(_WIN32) |
---|
42 | __declspec(dllexport) |
---|
43 | #endif |
---|
44 | geek() {} |
---|
45 | """) |
---|
46 | |
---|
47 | t.write("a/Jamfile", """ |
---|
48 | lib a : a.cpp ; |
---|
49 | """) |
---|
50 | |
---|
51 | t.write("b/b.cpp", """ |
---|
52 | void geek(); |
---|
53 | |
---|
54 | void |
---|
55 | #if defined(_WIN32) |
---|
56 | __declspec(dllexport) |
---|
57 | #endif |
---|
58 | foo() { geek(); } |
---|
59 | |
---|
60 | """) |
---|
61 | |
---|
62 | t.write("b/Jamfile", """ |
---|
63 | lib b : b.cpp ../a//a ; |
---|
64 | """) |
---|
65 | |
---|
66 | t.run_build_system(stderr=None) |
---|
67 | t.expect_addition("bin/$toolset/debug/main.exe") |
---|
68 | t.rm(["bin", "a/bin", "b/bin"]) |
---|
69 | |
---|
70 | t.run_build_system("link=static") |
---|
71 | t.expect_addition("bin/$toolset/debug/link-static/main.exe") |
---|
72 | t.rm(["bin", "a/bin", "b/bin"]) |
---|
73 | |
---|
74 | # Check that <library> works for static linking. |
---|
75 | |
---|
76 | t.write("b/Jamfile", """ |
---|
77 | lib b : b.cpp : <library>../a//a ; |
---|
78 | """) |
---|
79 | t.run_build_system("link=static") |
---|
80 | t.expect_addition("bin/$toolset/debug/link-static/main.exe") |
---|
81 | |
---|
82 | t.rm(["bin", "a/bin", "b/bin"]) |
---|
83 | t.write("b/Jamfile", """ |
---|
84 | lib b : b.cpp ../a//a/<link>shared : <link>static ; |
---|
85 | """) |
---|
86 | |
---|
87 | t.run_build_system() |
---|
88 | t.expect_addition("bin/$toolset/debug/main.exe") |
---|
89 | t.rm(["bin", "a/bin", "b/bin"]) |
---|
90 | |
---|
91 | # Test that putting library in sources of a searched library |
---|
92 | # works. |
---|
93 | t.write("Jamfile", """ |
---|
94 | exe main : main.cpp png ; |
---|
95 | lib png : z : <name>png ; |
---|
96 | lib z : : <name>zzz ; |
---|
97 | """) |
---|
98 | t.run_build_system("-a -n -d+2") |
---|
99 | t.fail_test(string.find(t.stdout(), "zzz") == -1) |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | t.cleanup() |
---|