From 24affbdfdffc098c268c2c0d03fef8e40c7cfaa9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 20 Mar 2003 02:42:17 +0000 Subject: [PATCH] Account for Win32 idiosyncracies [SVN r18024] --- test/use_requirements.py | 236 +++++++++++++++++++++++++++------------ 1 file changed, 167 insertions(+), 69 deletions(-) diff --git a/test/use_requirements.py b/test/use_requirements.py index ce5c8e3a2..51b64d80b 100644 --- a/test/use_requirements.py +++ b/test/use_requirements.py @@ -5,20 +5,37 @@ t = Tester() # Test that use requirements on main target work t.write("project-root.jam", "import gcc ;") -t.write("Jamfile", """ - lib b : b.cpp : : : FOO ; + +t.write( + "Jamfile", +""" + lib b : b.cpp : shared:SHARED_B + : : FOO shared:SHARED_B + ; exe a : a.cpp b ; """) -t.write("b.cpp", -"""void -#ifdef _WIN32 + +t.write( + "b.cpp", +""" +void +#if defined(_WIN32) && defined(SHARED_B) __declspec(dllexport) #endif -foo() {}\n""") -t.write("a.cpp", """ +foo() {}\n +""") + +t.write( + "a.cpp", +""" #ifdef FOO -void foo() {} +void +# if defined(_WIN32) && defined(SHARED_B) +__declspec(dllexport) +# endif +foo() {} #endif + int main() { foo(); } """) @@ -29,18 +46,29 @@ t.run_build_system("--clean") # Test that use requirements on main target work, when they are referred using # 'dependency' features. t.write("project-root.jam", "import gcc ;") -t.write("Jamfile", """ - lib b : b.cpp : : : FOO ; + +t.write( + "Jamfile", +""" + lib b : b.cpp : shared:SHARED_B + : : FOO shared:SHARED_B + ; exe a : a.cpp : b ; """) -t.write("b.cpp", -"""void -#ifdef _WIN32 + +t.write( + "b.cpp", +""" +void +#if defined(_WIN32) && defined(SHARED_B) __declspec(dllexport) #endif -foo() {}\n""" -) -t.write("a.cpp", """ +foo() {} +""") + +t.write( + "a.cpp", +""" #ifdef FOO int main() { return 0; } #endif @@ -53,49 +81,71 @@ t.run_build_system("--clean") # Test that use requirement on project work t.write("Jamfile", "exe a : a.cpp lib/b ;") -t.write("lib/Jamfile", """ -project : - usage-requirements FOO + +t.write( + "lib/Jamfile", +""" +project + : requirements shared:SHARED_B + : usage-requirements FOO shared:SHARED_B ; lib b : b.cpp ; """) -t.write("lib/b.cpp", -"""void -#ifdef _WIN32 + +t.write( + "lib/b.cpp", +""" +void +#if defined(_WIN32) && defined(SHARED_B) __declspec(dllexport) #endif -foo() {}\n""") +foo() {}\n +""") + t.run_build_system() # Test that use requirements are inherited correctly t.write("Jamfile", "exe a : a.cpp lib/1/b ;") -t.write("a.cpp", """ +t.write( + "a.cpp", +""" #if defined(FOO) && defined(ZOO) void foo() {} #endif + int main() { foo(); } """) -t.write("lib/Jamfile", """ -project : - usage-requirements FOO +t.write( + "lib/Jamfile", +""" +project + : requirements + : usage-requirements FOO ; """) -t.write("lib/1/Jamfile", """ -project : - usage-requirements ZOO - ; +t.write( + "lib/1/Jamfile", +""" +project + : requirements shared:SHARED_B + : usage-requirements ZOO shared:SHARED_B + ; lib b : b.cpp ; """) -t.write("lib/1/b.cpp", -"""void -#ifdef _WIN32 + +t.write( + "lib/1/b.cpp", +""" +void +#if defined(_WIN32) && defined(SHARED_B) __declspec(dllexport) #endif -foo() {}\n""") +foo() {}\n +""") t.run_build_system() t.run_build_system("--clean") @@ -103,31 +153,45 @@ t.run_build_system("--clean") # Test that we correctly handle dependency features # in use requirements on target -t.write("Jamfile", """ - lib b : b.cpp : : : FOO ; +t.write( + "Jamfile", +""" + lib b : b.cpp : shared:SHARED_B + : : FOO shared:SHARED_B + ; + # Here's the test: we should correctly # handle dependency feature and get # use requirements from 'b'. - lib c : c.cpp : : : b ; + lib c : c.cpp : shared:SHARED_C : : b ; + # This will build only if FOO # was propagated from 'c'. exe a : a.cpp c ; """) -t.write("a.cpp", """ + +t.write( + "a.cpp", +""" #ifdef FOO void -#ifdef _WIN32 -__declspec(dllimport) -#endif +# if defined(_WIN32) && defined(SHARED_B) +__declspec(dllexport) +# endif foo(); #endif + int main() { foo(); } """) -t.write("c.cpp", + +t.write( + "c.cpp", """ -#ifdef _WIN32 -int __declspec(dllexport) must_export_something; +int +#if defined(_WIN32) && defined(SHARED_C) +__declspec(dllexport) #endif +must_export_something; """) t.run_build_system() @@ -135,41 +199,60 @@ t.run_build_system("--clean") # Test correct handling of dependency features in # project requirements. -t.write("Jamfile", """ +t.write( + "Jamfile", +""" exe a : a.cpp lib1/c ; """) -t.write("lib1/Jamfile", """ +t.write( + "lib1/Jamfile", +""" project - : usage-requirements ../lib2/b - ; + : requirements shared:SHARED_C + : usage-requirements ../lib2/b shared:SHARED_C + ; + lib c : c.cpp ; """) -t.write("lib1/c.cpp", """ -#ifdef _WIN32 -int __declspec(dllexport) must_export_something; + +t.write( + "lib1/c.cpp", +""" +int +#if defined(_WIN32) && defined(SHARED_C) +__declspec(dllexport) #endif +must_export_something; """) -t.write("lib2/Jamfile", """ - lib b : b.cpp : : : FOO ; +t.write( + "lib2/Jamfile", +""" + lib b : b.cpp : shared:SHARED_B + : : FOO shared:SHARED_B ; """) + t.copy("b.cpp", "lib2/b.cpp") t.run_build_system() -# Test that dependency feature in use requirements are build +# Test that dependency feature in use requirements are built # with the correct properties t.rm(".") -t.write("Jamfile", """ +t.write( + "Jamfile", +""" lib main : main.cpp : : : libs/lib1 ; -exe hello : hello.cpp main ; +exe hello : hello.cpp main : ; """) -t.write("main.cpp", """ +t.write( + "main.cpp", +""" void -#ifdef _WIN32 +#if defined(_WIN32) && defined(SHARED_LIB1) __declspec(dllimport) #endif foo(); @@ -177,15 +260,19 @@ foo(); int main() { foo(); return 0; } """) -t.write("hello.cpp", "") +t.write("hello.cpp", "\n") -t.write("project-root.jam", """ +t.write( + "project-root.jam", +""" import gcc ; """) -t.write("libs/a.cpp", """ +t.write( + "libs/a.cpp", +""" void -#ifdef _WIN32 +#if defined(_WIN32) && defined(SHARED_LIB1) __declspec(dllexport) #endif foo() {} @@ -194,16 +281,27 @@ foo() {} # This library should be build with the same properties as # 'main'. There were a bug when they were generated with # empty properties, and there were ambiguity between variants. -t.write("libs/Jamfile", """ -lib lib1 : a_d.cpp : debug ; -lib lib1 : a.cpp : release ; +t.write( + "libs/Jamfile", +""" +lib lib1 : a_d.cpp : debug shared:SHARED_LIB1 +: : shared:SHARED_LIB1 ; + +lib lib1 : a.cpp : release shared:SHARED_LIB1 +: : shared:SHARED_LIB1 ; """) -t.write("libs/a_d.cpp", """ -void foo() {} +t.write( + "libs/a_d.cpp", +""" +void +#if defined(_WIN32) && defined(SHARED_LIB1) +__declspec(dllexport) +#endif +foo() {} """) t.run_build_system("link=static") -t.expect_addition("libs/bin/$toolset/debug/link-static/a_d.o") +t.expect_addition("libs/bin/$toolset/debug/link-static/a_d.obj") t.cleanup()