]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/pch.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / pch.py
CommitLineData
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
9import BoostBuild
92f5a8d4 10from time import sleep
7c673cae
FG
11
12
13t = BoostBuild.Tester()
14
15t.write("jamroot.jam", """
16import pch ;
20effc67 17project : requirements <warnings-as-errors>on ;
1e59de90
TL
18cpp-pch pch : pch.hpp ;
19cpp-pch pch-afx : pch.hpp : <define>HELLO ;
20cpp-pch pch-msvc-source : pch.hpp : <toolset>msvc:<source>pch.cpp ;
21exe hello : hello.cpp pch ;
22exe hello-afx : hello-afx.cpp pch-afx : <define>HELLO ;
23exe hello-msvc-source : hello-msvc-source.cpp pch-msvc-source ;
7c673cae
FG
24""")
25
1e59de90 26pch_content = """\
20effc67 27#undef HELLO
7c673cae
FG
28class TestClass
29{
30public:
31 TestClass( int, int ) {}
32};
1e59de90
TL
33"""
34t.write("pch.hpp", pch_content)
7c673cae
FG
35
36t.write("pch.cpp", """#include <pch.hpp>
37""")
38
1e59de90
TL
39toolset = BoostBuild.get_toolset()
40for 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
44t.run_build_system()
b32b8144 45t.expect_addition("bin/$toolset/debug*/hello.exe")
20effc67 46t.expect_addition("bin/$toolset/debug*/hello-afx.exe")
1e59de90 47t.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
55t.rename("pch.hpp", "pch.hpp.orig")
56s = "THIS WILL NOT COMPILE. "
57t.write("pch.hpp", s + (len(pch_content) - len(s)) * 'x')
58t.copy_timestamp("pch.hpp.orig", "pch.hpp")
7c673cae 59
20effc67
TL
60t.rm("bin/$toolset/debug*/hello.obj")
61t.rm("bin/$toolset/debug*/hello-afx.obj")
1e59de90 62t.rm("bin/$toolset/debug*/hello-msvc-source.obj")
7c673cae
FG
63
64t.run_build_system()
b32b8144 65t.expect_addition("bin/$toolset/debug*/hello.obj")
20effc67 66t.expect_addition("bin/$toolset/debug*/hello-afx.obj")
1e59de90 67t.expect_addition("bin/$toolset/debug*/hello-msvc-source.obj")
7c673cae
FG
68
69t.cleanup()