1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright 2006 Vladimir Prus. |
---|
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 | import os |
---|
11 | |
---|
12 | t = Tester() |
---|
13 | |
---|
14 | t.write("Jamroot", """ |
---|
15 | |
---|
16 | import pch ; |
---|
17 | |
---|
18 | cpp-pch pch : pch.hpp : <toolset>msvc:<source>pch.cpp <include>. ; |
---|
19 | |
---|
20 | exe hello : hello.cpp pch : <include>. ; |
---|
21 | """) |
---|
22 | |
---|
23 | t.write("pch.hpp.bad", """ |
---|
24 | THIS WON'T COMPILE |
---|
25 | """) |
---|
26 | |
---|
27 | # Note that pch.hpp is written after pch.hpp.bad, so its timestamp won't |
---|
28 | # be less than timestamp of pch.hpp.bad. |
---|
29 | t.write("pch.hpp", """ |
---|
30 | class TestClass { |
---|
31 | public: |
---|
32 | TestClass(int, int) {} |
---|
33 | }; |
---|
34 | |
---|
35 | """) |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | t.write("pch.cpp", """ #include <pch.hpp> |
---|
40 | |
---|
41 | """) |
---|
42 | |
---|
43 | t.write("hello.cpp", """ #include <pch.hpp> |
---|
44 | |
---|
45 | int main() |
---|
46 | { |
---|
47 | TestClass c(1, 2); |
---|
48 | return 0; |
---|
49 | } |
---|
50 | |
---|
51 | """) |
---|
52 | |
---|
53 | t.run_build_system() |
---|
54 | |
---|
55 | t.expect_addition("bin/$toolset/debug/hello.exe") |
---|
56 | |
---|
57 | # Now make the header unusable, without changing timestamp. |
---|
58 | # If everything is OK, Boost.Build won't recreate PCH, and |
---|
59 | # compiler will happily use pre-compiled header, not noticing |
---|
60 | # that the real header is bad. |
---|
61 | |
---|
62 | t.copy_preserving_timestamp("pch.hpp.bad", "pch.hpp") |
---|
63 | |
---|
64 | t.rm("bin/$toolset/debug/hello.obj") |
---|
65 | |
---|
66 | t.run_build_system() |
---|
67 | t.expect_addition("bin/$toolset/debug/hello.obj") |
---|
68 | |
---|
69 | t.cleanup() |
---|
70 | |
---|