1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Test that default build clause actually has any effect. |
---|
4 | |
---|
5 | from BoostBuild import Tester, List |
---|
6 | t = Tester() |
---|
7 | |
---|
8 | t.write("project-root.jam", "import gcc ;") |
---|
9 | t.write("Jamfile", "exe a : a.cpp : : debug release ;") |
---|
10 | t.write("a.cpp", "int main() { return 0; }\n") |
---|
11 | |
---|
12 | t.run_build_system() |
---|
13 | t.expect_addition("bin/$toolset/debug/a.exe") |
---|
14 | t.expect_addition("bin/$toolset/release/a.exe") |
---|
15 | |
---|
16 | # Check that explictly-specified build variant supresses |
---|
17 | # default-build |
---|
18 | t.rm("bin") |
---|
19 | t.run_build_system("release") |
---|
20 | t.expect_addition(List("bin/$toolset/release/") * "a.exe a.obj") |
---|
21 | t.expect_nothing_more() |
---|
22 | |
---|
23 | # Now check that we can specify explicit build request and |
---|
24 | # default-build will be combined with it |
---|
25 | t.run_build_system("optimization=space") |
---|
26 | t.expect_addition("bin/$toolset/debug/optimization-space/a.exe") |
---|
27 | t.expect_addition("bin/$toolset/release/optimization-space/a.exe") |
---|
28 | |
---|
29 | # Test that default-build must be identical in all alternatives. Error case. |
---|
30 | t.write("Jamfile", """ |
---|
31 | exe a : a.cpp : : debug ; |
---|
32 | exe a : b.cpp : : ; |
---|
33 | """) |
---|
34 | expected="""error: default build must be identical in all alternatives |
---|
35 | main target is ./a |
---|
36 | with |
---|
37 | differing from previous default build <variant>debug |
---|
38 | |
---|
39 | """ |
---|
40 | t.run_build_system("-n --no-error-backtrace", status=1, stdout=expected) |
---|
41 | |
---|
42 | # Test that default-build must be identical in all alternatives. No Error case, empty default build. |
---|
43 | t.write("Jamfile", """ |
---|
44 | exe a : a.cpp : <variant>debug ; |
---|
45 | exe a : b.cpp : <variant>release ; |
---|
46 | """) |
---|
47 | t.run_build_system("-n --no-error-backtrace", status=0) |
---|
48 | |
---|
49 | |
---|
50 | # Now try a harder example: default build which contains <define> |
---|
51 | # should cause <define> to be present when "b" is compiled. |
---|
52 | # This happens only of "build-project b" is placed first. |
---|
53 | t.write("Jamfile", """ |
---|
54 | project |
---|
55 | : default-build <define>FOO |
---|
56 | ; |
---|
57 | |
---|
58 | build-project a ; |
---|
59 | build-project b ; |
---|
60 | """) |
---|
61 | |
---|
62 | t.write("a/Jamfile", """ |
---|
63 | exe a : a.cpp ../b//b ; |
---|
64 | """) |
---|
65 | t.write("a/a.cpp", """ |
---|
66 | #ifdef _WIN32 |
---|
67 | __declspec(dllimport) |
---|
68 | #endif |
---|
69 | void foo(); |
---|
70 | int main() { foo(); return 0; } |
---|
71 | """) |
---|
72 | |
---|
73 | t.write("b/Jamfile", """ |
---|
74 | lib b : b.cpp ; |
---|
75 | """) |
---|
76 | t.write("b/b.cpp", """ |
---|
77 | #ifdef FOO |
---|
78 | #ifdef _WIN32 |
---|
79 | __declspec(dllexport) |
---|
80 | #endif |
---|
81 | void foo() {} |
---|
82 | #endif |
---|
83 | """) |
---|
84 | |
---|
85 | t.run_build_system() |
---|
86 | |
---|
87 | t.cleanup() |
---|