]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/indirect_conditional.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / indirect_conditional.py
1 #!/usr/bin/python
2
3 # Copyright (C) 2006. Vladimir Prus
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 import BoostBuild
9
10 def test_basic():
11 t = BoostBuild.Tester(use_test_config=False)
12
13 t.write("jamroot.jam", """\
14 exe a1 : a1.cpp : <conditional>@a1-rule ;
15 rule a1-rule ( properties * )
16 {
17 if <variant>debug in $(properties)
18 {
19 return <define>OK ;
20 }
21 }
22
23 exe a2 : a2.cpp : <conditional>@$(__name__).a2-rule
24 <variant>debug:<optimization>speed ;
25 rule a2-rule ( properties * )
26 {
27 if <optimization>speed in $(properties)
28 {
29 return <define>OK ;
30 }
31 }
32
33 exe a3 : a3.cpp :
34 <conditional>@$(__name__).a3-rule-1
35 <conditional>@$(__name__).a3-rule-2 ;
36 rule a3-rule-1 ( properties * )
37 {
38 if <optimization>speed in $(properties)
39 {
40 return <define>OK ;
41 }
42 }
43 rule a3-rule-2 ( properties * )
44 {
45 if <variant>debug in $(properties)
46 {
47 return <optimization>speed ;
48 }
49 }
50 """)
51
52 t.write("a1.cpp", "#ifdef OK\nint main() {}\n#endif\n")
53 t.write("a2.cpp", "#ifdef OK\nint main() {}\n#endif\n")
54 t.write("a3.cpp", "#ifdef OK\nint main() {}\n#endif\n")
55
56 t.run_build_system()
57
58 t.expect_addition("bin/$toolset/debug*/a1.exe")
59 t.expect_addition("bin/$toolset/debug/optimization-speed*/a2.exe")
60 t.expect_addition("bin/$toolset/debug/optimization-speed*/a3.exe")
61
62 t.cleanup()
63
64
65 def test_glob_in_indirect_conditional():
66 """
67 Regression test: project-rules.glob rule run from inside an indirect
68 conditional should report an error as it depends on the 'currently loaded
69 project' concept and indirect conditional rules get called only after all
70 the project modules have already finished loading.
71
72 """
73 t = BoostBuild.Tester(use_test_config=False)
74
75 t.write("jamroot.jam", """\
76 use-project /library-example/foo : util/foo ;
77 build-project app ;
78 """)
79 t.write("app/app.cpp", "int main() {}\n");
80 t.write("app/jamfile.jam", "exe app : app.cpp /library-example/foo//bar ;")
81 t.write("util/foo/bar.cpp", """\
82 #ifdef _WIN32
83 __declspec(dllexport)
84 #endif
85 void foo() {}
86 """)
87 t.write("util/foo/jamfile.jam", """\
88 rule print-my-sources ( properties * )
89 {
90 ECHO My sources: ;
91 ECHO [ glob *.cpp ] ;
92 }
93 lib bar : bar.cpp : <conditional>@print-my-sources ;
94 """)
95
96 t.run_build_system(status=1)
97 t.expect_output_lines(["My sources:", "bar.cpp"], False)
98 t.expect_output_lines("error: Reference to the project currently being "
99 "loaded requested when there was no project module being loaded.")
100
101 t.cleanup()
102
103
104 test_basic()
105 test_glob_in_indirect_conditional()