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)
7 # Test that a chain of libraries works ok, no matter if we use static or shared
14 t = BoostBuild.Tester()
16 t.write("jamfile.jam", """
17 # Stage the binary, so that it will be relinked without hardcode-dll-paths. That
18 # will chech that we pass correct -rpath-link, even if not passing -rpath.
20 exe main : main.cpp b ;
23 t.write("main.cpp", """
28 t.write("jamroot.jam", """
31 t.write("a/a.cpp", """
44 t.write("a/jamfile.jam", """
48 t.write("b/b.cpp", """
57 t.write("b/jamfile.jam", """
58 lib b : b.cpp ../a//a ;
61 t.run_build_system("-d2", stderr=None)
62 t.expect_addition("bin/$toolset/debug/main.exe")
63 t.rm(["bin", "a/bin", "b/bin"])
65 t.run_build_system("link=static")
66 t.expect_addition("bin/$toolset/debug/link-static/main.exe")
67 t.rm(["bin", "a/bin", "b/bin"])
70 # Check that <library> works for static linking.
71 t.write("b/jamfile.jam", """
72 lib b : b.cpp : <library>../a//a ;
75 t.run_build_system("link=static")
76 t.expect_addition("bin/$toolset/debug/link-static/main.exe")
78 t.rm(["bin", "a/bin", "b/bin"])
80 t.write("b/jamfile.jam", """
81 lib b : b.cpp ../a//a/<link>shared : <link>static ;
85 t.expect_addition("bin/$toolset/debug/main.exe")
87 t.rm(["bin", "a/bin", "b/bin"])
90 # Test that putting a library in sources of a searched library works.
91 t.write("jamfile.jam", """
92 exe main : main.cpp png ;
93 lib png : z : <name>png ;
97 t.run_build_system("-a -d+2", status=None, stderr=None)
98 # Try to find the "zzz" string either in response file (for Windows compilers),
99 # or in the standard output.
100 rsp = t.adjust_names("bin/$toolset/debug/main.exe.rsp")[0]
101 if os.path.exists(rsp) and ( string.find(open(rsp).read(), "zzz") != -1 ):
103 elif string.find(t.stdout(), "zzz") != -1:
108 # Test main -> libb -> liba chain in the case where liba is a file and not a
109 # Boost.Build target.
112 t.write("jamroot.jam", "")
114 t.write("a/jamfile.jam", """
119 t.write("a/a.cpp", """
121 __declspec(dllexport)
126 t.run_build_system(subdir="a")
127 t.expect_addition("a/dist/a.dll")
129 if ( ( os.name == 'nt' ) or os.uname()[0].lower().startswith('cygwin') ) and \
130 ( BoostBuild.get_toolset() != 'gcc' ):
131 # This is windows import library -- we know the exact name.
132 file = "a/dist/a.lib"
134 file = t.adjust_names(["a/dist/a.dll"])[0]
136 t.write("b/jamfile.jam", """
137 lib b : b.cpp ../%s ;
140 t.write("b/b.cpp", """
142 __declspec(dllimport)
146 __declspec(dllexport)
151 t.write("jamroot.jam", """
152 exe main : main.cpp b//b ;
155 t.write("main.cpp", """
157 __declspec(dllimport)
164 t.expect_addition("bin/$toolset/debug/main.exe")