⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library_chain.py

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 PY
字号:
#!/usr/bin/python# Copyright 2003, 2004, 2005, 2006 Vladimir Prus# Distributed under the Boost Software License, Version 1.0.# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)# Test that a chain of libraries works ok, no matter if we use static or shared# linking.import BoostBuildimport stringimport ost = BoostBuild.Tester()t.write("jamfile.jam", """# Stage the binary, so that it will be relinked without hardcode-dll-paths. That# will chech that we pass correct -rpath-link, even if not passing -rpath.stage dist : main ;exe main : main.cpp b ;""")t.write("main.cpp", """void foo();int main() { foo(); }""")t.write("jamroot.jam", """""")t.write("a/a.cpp", """void#if defined(_WIN32)__declspec(dllexport)#endifgee() {}void#if defined(_WIN32)__declspec(dllexport)#endifgeek() {}""")t.write("a/jamfile.jam", """lib a : a.cpp ;""")t.write("b/b.cpp", """void geek();void#if defined(_WIN32)__declspec(dllexport)#endiffoo() { geek(); }""")t.write("b/jamfile.jam", """lib b : b.cpp ../a//a ;""")t.run_build_system(stderr=None)t.expect_addition("bin/$toolset/debug/main.exe")t.rm(["bin", "a/bin", "b/bin"])t.run_build_system("link=static")t.expect_addition("bin/$toolset/debug/link-static/main.exe")t.rm(["bin", "a/bin", "b/bin"])# Check that <library> works for static linking.t.write("b/jamfile.jam", """lib b : b.cpp : <library>../a//a ;""")t.run_build_system("link=static")t.expect_addition("bin/$toolset/debug/link-static/main.exe")t.rm(["bin", "a/bin", "b/bin"])t.write("b/jamfile.jam", """lib b : b.cpp ../a//a/<link>shared : <link>static ;""")t.run_build_system()t.expect_addition("bin/$toolset/debug/main.exe")t.rm(["bin", "a/bin", "b/bin"])# Test that putting a library in sources of a searched library works.t.write("jamfile.jam", """exe main : main.cpp png ;lib png : z : <name>png ;lib z : : <name>zzz ;""")t.run_build_system("-a -d+2", status=None, stderr=None)# Try to find the "zzz" string either in response file (for Windows compilers),# or in the standard output.rsp = t.adjust_names("bin/$toolset/debug/main.exe.rsp")[0]if os.path.exists(rsp) and ( string.find(open(rsp).read(), "zzz") != -1 ):    passelif string.find(t.stdout(), "zzz") != -1:    passelse:    t.fail_test(1)# Test main -> libb -> liba chain in the case where liba is a file and not a# Boost.Build target.t.rm(".")t.write("jamroot.jam", "")t.write("a/jamfile.jam", """lib a : a.cpp ;install dist : a ;""")t.write("a/a.cpp", """#if defined(_WIN32)__declspec(dllexport)#endifvoid a() {}""")t.run_build_system(subdir="a")t.expect_addition("a/dist/a.dll")if ( ( os.name == 'nt' ) or os.uname()[0].lower().startswith('cygwin') ) and \    ( BoostBuild.get_toolset() != 'gcc' ):    # This is windows import library -- we know the exact name.    file = "a/dist/a.lib"else:    file = t.adjust_names(["a/dist/a.dll"])[0]t.write("b/jamfile.jam", """lib b : b.cpp ../%s ;""" % file)t.write("b/b.cpp", """#if defined(_WIN32)__declspec(dllimport)#endifvoid a();#if defined(_WIN32)__declspec(dllexport)#endifvoid b() { a(); }""")t.write("jamroot.jam", """exe main : main.cpp b//b ;""")t.write("main.cpp", """#if defined(_WIN32)__declspec(dllimport)#endifvoid b();int main() { b(); }""")t.run_build_system()t.expect_addition("bin/$toolset/debug/main.exe")t.cleanup()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -