1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) Vladimir Prus 2006. |
---|
4 | # Distributed under the Boost Software License, Version 1.0. (See |
---|
5 | # accompanying file LICENSE_1_0.txt or copy at |
---|
6 | # http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | |
---|
8 | from BoostBuild import Tester, List |
---|
9 | import string |
---|
10 | |
---|
11 | t = Tester() |
---|
12 | |
---|
13 | t.write("a.cpp", """ |
---|
14 | int main() {} |
---|
15 | |
---|
16 | """) |
---|
17 | |
---|
18 | t.write("Jamroot", """ |
---|
19 | exe a : a.cpp sub1//sub1 sub2//sub2 sub3//sub3 ; |
---|
20 | """) |
---|
21 | |
---|
22 | t.write("sub1/Jamfile", """ |
---|
23 | lib sub1 : sub1.cpp sub1_2 ../sub2//sub2 ; |
---|
24 | lib sub1_2 : sub1_2.cpp ; |
---|
25 | """) |
---|
26 | |
---|
27 | t.write("sub1/sub1.cpp", """ |
---|
28 | #ifdef _WIN32 |
---|
29 | __declspec(dllexport) |
---|
30 | #endif |
---|
31 | void sub1() {} |
---|
32 | |
---|
33 | """) |
---|
34 | |
---|
35 | t.write("sub1/sub1_2.cpp", """ |
---|
36 | #ifdef _WIN32 |
---|
37 | __declspec(dllexport) |
---|
38 | #endif |
---|
39 | void sub1() {} |
---|
40 | |
---|
41 | """) |
---|
42 | |
---|
43 | |
---|
44 | t.write("sub2/Jamfile", """ |
---|
45 | lib sub2 : sub2.cpp ; |
---|
46 | """) |
---|
47 | |
---|
48 | t.write("sub2/sub2.cpp", """ |
---|
49 | #ifdef _WIN32 |
---|
50 | __declspec(dllexport) |
---|
51 | #endif |
---|
52 | void sub2() {} |
---|
53 | |
---|
54 | """) |
---|
55 | |
---|
56 | t.write("sub3/Jamroot", """ |
---|
57 | lib sub3 : sub3.cpp ; |
---|
58 | """) |
---|
59 | |
---|
60 | t.write("sub3/sub3.cpp", """ |
---|
61 | #ifdef _WIN32 |
---|
62 | __declspec(dllexport) |
---|
63 | #endif |
---|
64 | void sub3() {} |
---|
65 | |
---|
66 | """) |
---|
67 | |
---|
68 | |
---|
69 | # The 'clean' should not remove files under separate Jamroot. |
---|
70 | t.run_build_system() |
---|
71 | t.run_build_system("--clean") |
---|
72 | t.expect_removal("bin/$toolset/debug/a.obj") |
---|
73 | t.expect_removal("sub1/bin/$toolset/debug/sub1.obj") |
---|
74 | t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj") |
---|
75 | t.expect_removal("sub2/bin/$toolset/debug/sub2.obj") |
---|
76 | t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj") |
---|
77 | |
---|
78 | # The 'clean-all' removes everything it can reach. |
---|
79 | t.run_build_system() |
---|
80 | t.run_build_system("--clean") |
---|
81 | t.expect_removal("bin/$toolset/debug/a.obj") |
---|
82 | t.expect_removal("sub1/bin/$toolset/debug/sub1.obj") |
---|
83 | t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj") |
---|
84 | t.expect_removal("sub2/bin/$toolset/debug/sub2.obj") |
---|
85 | t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj") |
---|
86 | |
---|
87 | # The 'clean' together with project target removes |
---|
88 | # only under that probject |
---|
89 | t.run_build_system() |
---|
90 | t.run_build_system("sub1 --clean") |
---|
91 | t.expect_nothing("bin/$toolset/debug/a.obj") |
---|
92 | t.expect_removal("sub1/bin/$toolset/debug/sub1.obj") |
---|
93 | t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj") |
---|
94 | t.expect_nothing("sub2/bin/$toolset/debug/sub2.obj") |
---|
95 | t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj") |
---|
96 | |
---|
97 | # And clean-all removes everything. |
---|
98 | t.run_build_system() |
---|
99 | t.run_build_system("sub1 --clean-all") |
---|
100 | t.expect_nothing("bin/$toolset/debug/a.obj") |
---|
101 | t.expect_removal("sub1/bin/$toolset/debug/sub1.obj") |
---|
102 | t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj") |
---|
103 | t.expect_removal("sub2/bin/$toolset/debug/sub2.obj") |
---|
104 | t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj") |
---|
105 | |
---|
106 | # If main target is explicitly named, we should not remove |
---|
107 | # files from other targets. |
---|
108 | |
---|
109 | t.run_build_system() |
---|
110 | t.run_build_system("sub1//sub1 --clean") |
---|
111 | t.expect_removal("sub1/bin/$toolset/debug/sub1.obj") |
---|
112 | t.expect_nothing("sub1/bin/$toolset/debug/sub1_2.obj") |
---|
113 | t.expect_nothing("sub2/bin/$toolset/debug/sub2.obj") |
---|
114 | t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj") |
---|
115 | |
---|
116 | |
---|
117 | # Regression test: sources of the 'cast' rule were mistakenly |
---|
118 | # deleted. |
---|
119 | t.rm(".") |
---|
120 | t.write("Jamroot", """ |
---|
121 | import cast ; |
---|
122 | cast a cpp : a.h ; |
---|
123 | """) |
---|
124 | t.write("a.h", "") |
---|
125 | |
---|
126 | t.run_build_system("--clean") |
---|
127 | t.expect_nothing("a.h") |
---|
128 | |
---|
129 | t.cleanup() |
---|
130 | |
---|