]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/preprocessor.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / test / preprocessor.py
1 #!/usr/bin/python
2
3 # Copyright 2003 Vladimir Prus
4 # Copyright 2011 Steven Watanabe
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7
8 # Test the C/C++ preprocessor.
9
10 import BoostBuild
11
12 t = BoostBuild.Tester()
13
14 t.write("jamroot.jam", """
15 project ;
16 preprocessed hello : hello.cpp ;
17 preprocessed a : a.c ;
18 exe hello.exe : hello a : <define>FAIL ;
19 """)
20
21 t.write("hello.cpp", """
22 #ifndef __cplusplus
23 #error "This file must be compiled as C++"
24 #endif
25 #ifdef FAIL
26 #error "Not preprocessed?"
27 #endif
28 extern "C" int foo();
29 int main() { return foo(); }
30 """)
31
32 t.write("a.c", """
33 /* This will not compile unless in C mode. */
34 #ifdef __cplusplus
35 #error "This file must be compiled as C"
36 #endif
37 #ifdef FAIL
38 #error "Not preprocessed?"
39 #endif
40 int foo()
41 {
42 int new = 0;
43 new = (new+1)*7;
44 return new;
45 }
46 """)
47
48 t.run_build_system()
49 t.expect_addition("bin/$toolset/debug/hello.ii")
50 t.expect_addition("bin/$toolset/debug/a.i")
51 t.expect_addition("bin/$toolset/debug/hello.exe")
52
53 t.cleanup()