]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/inherited_dependency.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / inherited_dependency.py
CommitLineData
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
9import BoostBuild
10
11tester = BoostBuild.Tester(use_test_config=False)
12
13
14################################################################################
15#
16# Test without giving the project an explicit id.
17#
18################################################################################
19
20tester.write("jamroot.jam", """
21lib test : test.cpp ;
22project : requirements <library>test ;
23build-project a ;
24""")
25
26tester.write("test.cpp", """
27#ifdef _WIN32
28 __declspec(dllexport)
29#endif
30void foo() {}
31""")
32
33tester.write("a/test1.cpp", """
34int main() {}
35""")
36
37tester.write("a/jamfile.jam", """
38exe test1 : test1.cpp ;
39""")
40
41tester.run_build_system()
42
b32b8144
FG
43tester.expect_addition("bin/$toolset/debug*/test.obj")
44tester.expect_addition("a/bin/$toolset/debug*/test1.exe")
7c673cae
FG
45
46tester.rm("bin")
47tester.rm("a/bin")
48
49
50################################################################################
51#
52# Run the same test from the "a" directory.
53#
54################################################################################
55
56tester.run_build_system(subdir="a")
57
b32b8144
FG
58tester.expect_addition("bin/$toolset/debug*/test.obj")
59tester.expect_addition("a/bin/$toolset/debug*/test1.exe")
7c673cae
FG
60
61tester.rm("bin")
62tester.rm("a/bin")
63
64
65################################################################################
66#
67# This time, do give the project an id.
68#
69################################################################################
70
71tester.write("jamroot.jam", """
72lib test : test.cpp ;
73project test_project : requirements <library>test ;
74build-project a ;
75""")
76
77tester.run_build_system()
78
b32b8144
FG
79tester.expect_addition("bin/$toolset/debug*/test.obj")
80tester.expect_addition("a/bin/$toolset/debug*/test1.exe")
7c673cae
FG
81
82tester.rm("bin")
83tester.rm("a/bin")
84
85
86################################################################################
87#
88# Now, give the project an id in its attributes.
89#
90################################################################################
91
92tester.write("jamroot.jam", """
93lib test : test.cpp ;
94project : id test_project : requirements <library>test ;
95build-project a ;
96""")
97
98tester.run_build_system()
99
b32b8144
FG
100tester.expect_addition("bin/$toolset/debug*/test.obj")
101tester.expect_addition("a/bin/$toolset/debug*/test1.exe")
7c673cae
FG
102
103tester.rm("bin")
104tester.rm("a/bin")
105
106
107################################################################################
108#
109# Give the project an id in both ways at once.
110#
111################################################################################
112
113tester.write("jamroot.jam", """
114lib test : test.cpp ;
115project test_project1 : id test_project : requirements <library>test ;
116build-project a ;
117""")
118
119tester.run_build_system()
120
b32b8144
FG
121tester.expect_addition("bin/$toolset/debug*/test.obj")
122tester.expect_addition("a/bin/$toolset/debug*/test1.exe")
7c673cae
FG
123
124tester.rm("bin")
125tester.rm("a/bin")
126
127
128################################################################################
129#
130# Test an absolute path in native format.
131#
132################################################################################
133
134tester.write("jamroot.jam", """
135import path ;
136path-constant here : . ;
137current-location = [ path.native [ path.root [ path.make $(here) ] [ path.pwd ]
138 ] ] ;
139project test : requirements <source>$(current-location)/a/test1.cpp ;
140exe test : test.cpp ;
141""")
142
143tester.run_build_system()
b32b8144 144tester.expect_addition("bin/$toolset/debug*/test.exe")
7c673cae
FG
145
146tester.rm("bin")
147tester.rm("a/bin")
148
149
150################################################################################
151#
152# Test an absolute path in canonical format.
153#
154################################################################################
155
156tester.write("jamroot.jam", """
157import path ;
158path-constant here : . ;
159current-location = [ path.root [ path.make $(here) ] [ path.pwd ] ] ;
160project test : requirements <source>$(current-location)/a/test1.cpp ;
161exe test : test.cpp ;
162""")
163
164tester.run_build_system()
b32b8144 165tester.expect_addition("bin/$toolset/debug*/test.exe")
7c673cae
FG
166
167tester.rm("bin")
168tester.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.
180tester.write("b/jamroot.jam", """
181obj test3 : test3.cpp ;
182""")
183
184tester.write("b/test3.cpp", """
185void bar() {}
186""")
187
188tester.write("jamroot.jam", """
189project test : requirements <source>b//test3 ;
190build-project a ;
191""")
192
193tester.write("a/jamfile.jam", """
194exe test : test1.cpp ;
195""")
196
197tester.write("a/test1.cpp", """
198void bar();
199int main() { bar(); }
200""")
201
202tester.run_build_system()
b32b8144
FG
203tester.expect_addition("b/bin/$toolset/debug*/test3.obj")
204tester.expect_addition("a/bin/$toolset/debug*/test.exe")
7c673cae
FG
205
206tester.rm("bin")
207tester.rm("a")
208tester.rm("jamroot.jam")
209tester.rm("test.cpp")
210
211
212################################################################################
213#
214# Test that source-location is respected.
215#
216################################################################################
217
218tester.write("build/jamroot.jam", """
219project : requirements <source>test.cpp : source-location ../src ;
220""")
221
222tester.write("src/test.cpp", """
223int main() {}
224""")
225
226tester.write("build/a/jamfile.jam", """
227project : source-location ../../a_src ;
228exe test : test1.cpp ;
229""")
230
231tester.write("a_src/test1.cpp", """
232""")
233
234tester.run_build_system(subdir="build/a")
b32b8144 235tester.expect_addition("build/a/bin/$toolset/debug*/test.exe")
7c673cae
FG
236
237tester.cleanup()