]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/rescan_header.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / tools / build / test / rescan_header.py
CommitLineData
7c673cae
FG
1#!/usr/bin/python
2
3# Copyright 2012 Steven Watanabe
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7import BoostBuild
8
9t = BoostBuild.Tester(use_test_config=False)
10
11# Test a header loop that depends on (but does not contain) a generated header.
12t.write("test.cpp", '#include "header1.h"\n')
13
14t.write("header1.h", """\
15#ifndef HEADER1_H
16#define HEADER1_H
17#include "header2.h"
18#endif
19""")
20
21t.write("header2.h", """\
22#ifndef HEADER2_H
23#define HEADER2_H
24#include "header1.h"
25#include "header3.h"
26#endif
27""")
28
29t.write("header3.in", "/* empty file */\n")
30
31t.write("jamroot.jam", """\
32import common ;
33make header3.h : header3.in : @common.copy ;
34obj test : test.cpp : <implicit-dependency>header3.h ;
35""")
36
37t.run_build_system(["-j2"])
11fdf7f2 38t.expect_addition("bin/header3.h")
b32b8144 39t.expect_addition("bin/$toolset/debug*/test.obj")
7c673cae
FG
40t.expect_nothing_more()
41
42t.rm(".")
43
44# Test a linear sequence of generated headers.
45t.write("test.cpp", '#include "header1.h"\n')
46
47t.write("header1.in", """\
48#ifndef HEADER1_H
49#define HEADER1_H
50#include "header2.h"
51#endif
52""")
53
54t.write("header2.in", """\
55#ifndef HEADER2_H
56#define HEADER2_H
57#include "header3.h"
58#endif
59""")
60
61t.write("header3.in", "/* empty file */\n")
62
63t.write("jamroot.jam", """\
64import common ;
65make header1.h : header1.in : @common.copy ;
66make header2.h : header2.in : @common.copy ;
67make header3.h : header3.in : @common.copy ;
68obj test : test.cpp :
69 <implicit-dependency>header1.h
70 <implicit-dependency>header2.h
71 <implicit-dependency>header3.h ;
72""")
73
74t.run_build_system(["-j2", "test"])
11fdf7f2
TL
75t.expect_addition("bin/header1.h")
76t.expect_addition("bin/header2.h")
77t.expect_addition("bin/header3.h")
b32b8144 78t.expect_addition("bin/$toolset/debug*/test.obj")
7c673cae
FG
79t.expect_nothing_more()
80
81t.rm(".")
82
83# Test a loop in generated headers.
84t.write("test.cpp", '#include "header1.h"\n')
85
86t.write("header1.in", """\
87#ifndef HEADER1_H
88#define HEADER1_H
89#include "header2.h"
90#endif
91""")
92
93t.write("header2.in", """\
94#ifndef HEADER2_H
95#define HEADER2_H
96#include "header3.h"
97#endif
98""")
99
100t.write("header3.in", """\
101#ifndef HEADER2_H
102#define HEADER2_H
103#include "header1.h"
104#endif
105""")
106
107t.write("jamroot.jam", """\
108import common ;
109
110actions copy {
111 sleep 1
112 cp $(>) $(<)
113}
114
115make header1.h : header1.in : @common.copy ;
116make header2.h : header2.in : @common.copy ;
117make header3.h : header3.in : @common.copy ;
118obj test : test.cpp :
119 <implicit-dependency>header1.h
120 <implicit-dependency>header2.h
121 <implicit-dependency>header3.h ;
122""")
123
124t.run_build_system(["-j2", "test"])
11fdf7f2
TL
125t.expect_addition("bin/header1.h")
126t.expect_addition("bin/header2.h")
127t.expect_addition("bin/header3.h")
b32b8144 128t.expect_addition("bin/$toolset/debug*/test.obj")
7c673cae
FG
129t.expect_nothing_more()
130
131t.rm(".")
132
133# Test that all the dependencies of a loop are updated before any of the
134# dependents.
135t.write("test1.cpp", '#include "header1.h"\n')
136
137t.write("test2.cpp", """\
138#include "header2.h"
139int main() {}
140""")
141
142t.write("header1.h", """\
143#ifndef HEADER1_H
144#define HEADER1_H
145#include "header2.h"
146#endif
147""")
148
149t.write("header2.h", """\
150#ifndef HEADER2_H
151#define HEADER2_H
152#include "header1.h"
153#include "header3.h"
154#endif
155""")
156
157t.write("header3.in", "\n")
158
159t.write("sleep.bat", """\
160::@timeout /T %1 /NOBREAK >nul
161@ping 127.0.0.1 -n 2 -w 1000 >nul
162@ping 127.0.0.1 -n %1 -w 1000 >nul
163@exit /B 0
164""")
165
166t.write("jamroot.jam", """\
167import common ;
168import os ;
169
170if [ os.name ] = NT
171{
172 SLEEP = call sleep.bat ;
173}
174else
175{
176 SLEEP = sleep ;
177}
178
179rule copy { common.copy $(<) : $(>) ; }
180actions copy { $(SLEEP) 1 }
181
182make header3.h : header3.in : @copy ;
183exe test : test2.cpp test1.cpp : <implicit-dependency>header3.h ;
184""")
185
186t.run_build_system(["-j2", "test"])
11fdf7f2 187t.expect_addition("bin/header3.h")
b32b8144
FG
188t.expect_addition("bin/$toolset/debug*/test1.obj")
189t.expect_addition("bin/$toolset/debug*/test2.obj")
190t.expect_addition("bin/$toolset/debug*/test.exe")
7c673cae
FG
191t.expect_nothing_more()
192
193t.touch("header3.in")
194t.run_build_system(["-j2", "test"])
11fdf7f2 195t.expect_touch("bin/header3.h")
b32b8144
FG
196t.expect_touch("bin/$toolset/debug*/test1.obj")
197t.expect_touch("bin/$toolset/debug*/test2.obj")
198t.expect_touch("bin/$toolset/debug*/test.exe")
7c673cae
FG
199t.expect_nothing_more()
200
201t.rm(".")
202
203# Test a loop that includes a generated header
204t.write("test1.cpp", '#include "header1.h"\n')
205t.write("test2.cpp", """\
206#include "header2.h"
207int main() {}
208""")
209
210t.write("header1.h", """\
211#ifndef HEADER1_H
212#define HEADER1_H
213#include "header2.h"
214#endif
215""")
216
217t.write("header2.in", """\
218#ifndef HEADER2_H
219#define HEADER2_H
220#include "header3.h"
221#endif
222""")
223
224t.write("header3.h", """\
225#ifndef HEADER3_H
226#define HEADER3_H
227#include "header1.h"
228#endif
229""")
230
231t.write("sleep.bat", """\
232::@timeout /T %1 /NOBREAK >nul
233@ping 127.0.0.1 -n 2 -w 1000 >nul
234@ping 127.0.0.1 -n %1 -w 1000 >nul
235@exit /B 0
236""")
237
238t.write("jamroot.jam", """\
239import common ;
240import os ;
241
242if [ os.name ] = NT
243{
244 SLEEP = call sleep.bat ;
245}
246else
247{
248 SLEEP = sleep ;
249}
250
251rule copy { common.copy $(<) : $(>) ; }
252actions copy { $(SLEEP) 1 }
253
254make header2.h : header2.in : @copy ;
255exe test : test2.cpp test1.cpp : <implicit-dependency>header2.h <include>. ;
256""")
257
258t.run_build_system(["-j2", "test"])
11fdf7f2 259t.expect_addition("bin/header2.h")
b32b8144
FG
260t.expect_addition("bin/$toolset/debug*/test1.obj")
261t.expect_addition("bin/$toolset/debug*/test2.obj")
262t.expect_addition("bin/$toolset/debug*/test.exe")
7c673cae
FG
263t.expect_nothing_more()
264
265t.cleanup()