]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2006 Vladimir Prus. | |
1e59de90 | 4 | # Copyright Nikita Kniazev 2020. |
7c673cae | 5 | # Distributed under the Boost Software License, Version 1.0. (See |
1e59de90 TL |
6 | # accompanying file LICENSE.txt or copy at |
7 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
8 | |
9 | import BoostBuild | |
92f5a8d4 | 10 | from time import sleep |
7c673cae FG |
11 | |
12 | ||
13 | t = BoostBuild.Tester() | |
14 | ||
15 | t.write("jamroot.jam", """ | |
16 | import pch ; | |
20effc67 | 17 | project : requirements <warnings-as-errors>on ; |
1e59de90 TL |
18 | cpp-pch pch : pch.hpp ; |
19 | cpp-pch pch-afx : pch.hpp : <define>HELLO ; | |
20 | cpp-pch pch-msvc-source : pch.hpp : <toolset>msvc:<source>pch.cpp ; | |
21 | exe hello : hello.cpp pch ; | |
22 | exe hello-afx : hello-afx.cpp pch-afx : <define>HELLO ; | |
23 | exe hello-msvc-source : hello-msvc-source.cpp pch-msvc-source ; | |
7c673cae FG |
24 | """) |
25 | ||
1e59de90 | 26 | pch_content = """\ |
20effc67 | 27 | #undef HELLO |
7c673cae FG |
28 | class TestClass |
29 | { | |
30 | public: | |
31 | TestClass( int, int ) {} | |
32 | }; | |
1e59de90 TL |
33 | """ |
34 | t.write("pch.hpp", pch_content) | |
7c673cae FG |
35 | |
36 | t.write("pch.cpp", """#include <pch.hpp> | |
37 | """) | |
38 | ||
1e59de90 TL |
39 | toolset = BoostBuild.get_toolset() |
40 | for name in ("hello.cpp", "hello-afx.cpp", "hello-msvc-source.cpp"): | |
41 | t.write(name, """int main() { TestClass c(1, 2); } | |
7c673cae FG |
42 | """) |
43 | ||
44 | t.run_build_system() | |
b32b8144 | 45 | t.expect_addition("bin/$toolset/debug*/hello.exe") |
20effc67 | 46 | t.expect_addition("bin/$toolset/debug*/hello-afx.exe") |
1e59de90 | 47 | t.expect_addition("bin/$toolset/debug*/hello-msvc-source.exe") |
7c673cae FG |
48 | |
49 | ||
1e59de90 TL |
50 | # Now make the header unusable, replace its content with some garbage, but |
51 | # preserve the size and timestamp to fool the compiler. If everything is OK, | |
f67539c2 | 52 | # B2 will not recreate PCH, and compiler will happily use pre-compiled |
7c673cae FG |
53 | # header, not noticing that the real header is bad. |
54 | ||
1e59de90 TL |
55 | t.rename("pch.hpp", "pch.hpp.orig") |
56 | s = "THIS WILL NOT COMPILE. " | |
57 | t.write("pch.hpp", s + (len(pch_content) - len(s)) * 'x') | |
58 | t.copy_timestamp("pch.hpp.orig", "pch.hpp") | |
7c673cae | 59 | |
20effc67 TL |
60 | t.rm("bin/$toolset/debug*/hello.obj") |
61 | t.rm("bin/$toolset/debug*/hello-afx.obj") | |
1e59de90 | 62 | t.rm("bin/$toolset/debug*/hello-msvc-source.obj") |
7c673cae FG |
63 | |
64 | t.run_build_system() | |
b32b8144 | 65 | t.expect_addition("bin/$toolset/debug*/hello.obj") |
20effc67 | 66 | t.expect_addition("bin/$toolset/debug*/hello-afx.obj") |
1e59de90 | 67 | t.expect_addition("bin/$toolset/debug*/hello-msvc-source.obj") |
7c673cae FG |
68 | |
69 | t.cleanup() |