]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | # | |
3 | # Copyright (c) 2008 Steven Watanabe | |
4 | # | |
5 | # Distributed under the Boost Software License, Version 1.0. (See | |
6 | # accompanying file LICENSE_1_0.txt) or copy at | |
7 | # http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | import BoostBuild | |
10 | ||
11 | tester = BoostBuild.Tester(use_test_config=False) | |
12 | ||
13 | ||
14 | ################################################################################ | |
15 | # | |
16 | # Test without giving the project an explicit id. | |
17 | # | |
18 | ################################################################################ | |
19 | ||
20 | tester.write("jamroot.jam", """ | |
21 | lib test : test.cpp ; | |
22 | project : requirements <library>test ; | |
23 | build-project a ; | |
24 | """) | |
25 | ||
26 | tester.write("test.cpp", """ | |
27 | #ifdef _WIN32 | |
28 | __declspec(dllexport) | |
29 | #endif | |
30 | void foo() {} | |
31 | """) | |
32 | ||
33 | tester.write("a/test1.cpp", """ | |
34 | int main() {} | |
35 | """) | |
36 | ||
37 | tester.write("a/jamfile.jam", """ | |
38 | exe test1 : test1.cpp ; | |
39 | """) | |
40 | ||
41 | tester.run_build_system() | |
42 | ||
b32b8144 FG |
43 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
44 | tester.expect_addition("a/bin/$toolset/debug*/test1.exe") | |
7c673cae FG |
45 | |
46 | tester.rm("bin") | |
47 | tester.rm("a/bin") | |
48 | ||
49 | ||
50 | ################################################################################ | |
51 | # | |
52 | # Run the same test from the "a" directory. | |
53 | # | |
54 | ################################################################################ | |
55 | ||
56 | tester.run_build_system(subdir="a") | |
57 | ||
b32b8144 FG |
58 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
59 | tester.expect_addition("a/bin/$toolset/debug*/test1.exe") | |
7c673cae FG |
60 | |
61 | tester.rm("bin") | |
62 | tester.rm("a/bin") | |
63 | ||
64 | ||
65 | ################################################################################ | |
66 | # | |
67 | # This time, do give the project an id. | |
68 | # | |
69 | ################################################################################ | |
70 | ||
71 | tester.write("jamroot.jam", """ | |
72 | lib test : test.cpp ; | |
73 | project test_project : requirements <library>test ; | |
74 | build-project a ; | |
75 | """) | |
76 | ||
77 | tester.run_build_system() | |
78 | ||
b32b8144 FG |
79 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
80 | tester.expect_addition("a/bin/$toolset/debug*/test1.exe") | |
7c673cae FG |
81 | |
82 | tester.rm("bin") | |
83 | tester.rm("a/bin") | |
84 | ||
85 | ||
86 | ################################################################################ | |
87 | # | |
88 | # Now, give the project an id in its attributes. | |
89 | # | |
90 | ################################################################################ | |
91 | ||
92 | tester.write("jamroot.jam", """ | |
93 | lib test : test.cpp ; | |
94 | project : id test_project : requirements <library>test ; | |
95 | build-project a ; | |
96 | """) | |
97 | ||
98 | tester.run_build_system() | |
99 | ||
b32b8144 FG |
100 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
101 | tester.expect_addition("a/bin/$toolset/debug*/test1.exe") | |
7c673cae FG |
102 | |
103 | tester.rm("bin") | |
104 | tester.rm("a/bin") | |
105 | ||
106 | ||
107 | ################################################################################ | |
108 | # | |
109 | # Give the project an id in both ways at once. | |
110 | # | |
111 | ################################################################################ | |
112 | ||
113 | tester.write("jamroot.jam", """ | |
114 | lib test : test.cpp ; | |
115 | project test_project1 : id test_project : requirements <library>test ; | |
116 | build-project a ; | |
117 | """) | |
118 | ||
119 | tester.run_build_system() | |
120 | ||
b32b8144 FG |
121 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
122 | tester.expect_addition("a/bin/$toolset/debug*/test1.exe") | |
7c673cae FG |
123 | |
124 | tester.rm("bin") | |
125 | tester.rm("a/bin") | |
126 | ||
127 | ||
128 | ################################################################################ | |
129 | # | |
130 | # Test an absolute path in native format. | |
131 | # | |
132 | ################################################################################ | |
133 | ||
134 | tester.write("jamroot.jam", """ | |
135 | import path ; | |
136 | path-constant here : . ; | |
137 | current-location = [ path.native [ path.root [ path.make $(here) ] [ path.pwd ] | |
138 | ] ] ; | |
139 | project test : requirements <source>$(current-location)/a/test1.cpp ; | |
140 | exe test : test.cpp ; | |
141 | """) | |
142 | ||
143 | tester.run_build_system() | |
b32b8144 | 144 | tester.expect_addition("bin/$toolset/debug*/test.exe") |
7c673cae FG |
145 | |
146 | tester.rm("bin") | |
147 | tester.rm("a/bin") | |
148 | ||
149 | ||
150 | ################################################################################ | |
151 | # | |
152 | # Test an absolute path in canonical format. | |
153 | # | |
154 | ################################################################################ | |
155 | ||
156 | tester.write("jamroot.jam", """ | |
157 | import path ; | |
158 | path-constant here : . ; | |
159 | current-location = [ path.root [ path.make $(here) ] [ path.pwd ] ] ; | |
160 | project test : requirements <source>$(current-location)/a/test1.cpp ; | |
161 | exe test : test.cpp ; | |
162 | """) | |
163 | ||
164 | tester.run_build_system() | |
b32b8144 | 165 | tester.expect_addition("bin/$toolset/debug*/test.exe") |
7c673cae FG |
166 | |
167 | tester.rm("bin") | |
168 | tester.rm("a/bin") | |
169 | ||
170 | ||
171 | ################################################################################ | |
172 | # | |
173 | # Test dependency properties (e.g. <source>) whose targets are specified using a | |
174 | # relative path. | |
175 | # | |
176 | ################################################################################ | |
177 | ||
178 | # Use jamroot.jam rather than jamfile.jam to avoid inheriting the <source> from | |
179 | # the parent as that would would make test3 a source of itself. | |
180 | tester.write("b/jamroot.jam", """ | |
181 | obj test3 : test3.cpp ; | |
182 | """) | |
183 | ||
184 | tester.write("b/test3.cpp", """ | |
185 | void bar() {} | |
186 | """) | |
187 | ||
188 | tester.write("jamroot.jam", """ | |
189 | project test : requirements <source>b//test3 ; | |
190 | build-project a ; | |
191 | """) | |
192 | ||
193 | tester.write("a/jamfile.jam", """ | |
194 | exe test : test1.cpp ; | |
195 | """) | |
196 | ||
197 | tester.write("a/test1.cpp", """ | |
198 | void bar(); | |
199 | int main() { bar(); } | |
200 | """) | |
201 | ||
202 | tester.run_build_system() | |
b32b8144 FG |
203 | tester.expect_addition("b/bin/$toolset/debug*/test3.obj") |
204 | tester.expect_addition("a/bin/$toolset/debug*/test.exe") | |
7c673cae FG |
205 | |
206 | tester.rm("bin") | |
207 | tester.rm("a") | |
208 | tester.rm("jamroot.jam") | |
209 | tester.rm("test.cpp") | |
210 | ||
211 | ||
212 | ################################################################################ | |
213 | # | |
214 | # Test that source-location is respected. | |
215 | # | |
216 | ################################################################################ | |
217 | ||
218 | tester.write("build/jamroot.jam", """ | |
219 | project : requirements <source>test.cpp : source-location ../src ; | |
220 | """) | |
221 | ||
222 | tester.write("src/test.cpp", """ | |
223 | int main() {} | |
224 | """) | |
225 | ||
226 | tester.write("build/a/jamfile.jam", """ | |
227 | project : source-location ../../a_src ; | |
228 | exe test : test1.cpp ; | |
229 | """) | |
230 | ||
231 | tester.write("a_src/test1.cpp", """ | |
232 | """) | |
233 | ||
234 | tester.run_build_system(subdir="build/a") | |
b32b8144 | 235 | tester.expect_addition("build/a/bin/$toolset/debug*/test.exe") |
7c673cae FG |
236 | |
237 | tester.cleanup() |