]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/alternatives.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / tools / build / test / alternatives.py
1 #!/usr/bin/python
2
3 # Copyright 2003 Dave Abrahams
4 # Copyright 2003, 2006 Vladimir Prus
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 main target alternatives.
9
10 import BoostBuild
11 import string
12
13 t = BoostBuild.Tester(use_test_config=False)
14
15 # Test that basic alternatives selection works.
16 t.write("jamroot.jam", "")
17
18 t.write("jamfile.jam", """
19 exe a : a_empty.cpp ;
20 exe a : a.cpp : <variant>release ;
21 """)
22
23 t.write("a_empty.cpp", "")
24
25 t.write("a.cpp", "int main() {}\n")
26
27 t.run_build_system(["release"])
28
29 t.expect_addition("bin/$toolset/release*/a.exe")
30
31 # Test that alternative selection works for ordinary properties, in particular
32 # user-defined.
33 t.write("jamroot.jam", "")
34
35 t.write("jamfile.jam", """
36 import feature ;
37 feature.feature X : off on : propagated ;
38 exe a : b.cpp ;
39 exe a : a.cpp : <X>on ;
40 """)
41 t.write("b.cpp", "int main() {}\n")
42
43 t.rm("bin")
44
45 t.run_build_system()
46 t.expect_addition("bin/$toolset/debug*/b.obj")
47
48 t.run_build_system(["X=on"])
49 t.expect_addition("bin/$toolset/debug/X-on*/a.obj")
50
51 t.rm("bin")
52
53 # Test that everything works ok even with the default build.
54 t.write("jamfile.jam", """\
55 exe a : a_empty.cpp : <variant>release ;
56 exe a : a.cpp : <variant>debug ;
57 """)
58
59 t.run_build_system()
60 t.expect_addition("bin/$toolset/debug*/a.exe")
61
62 # Test that only properties which are in the build request matter for
63 # alternative selection. IOW, alternative with <variant>release is better than
64 # one with <variant>debug when building the release variant.
65 t.write("jamfile.jam", """\
66 exe a : a_empty.cpp : <variant>debug ;
67 exe a : a.cpp : <variant>release ;
68 """)
69
70 t.run_build_system(["release"])
71 t.expect_addition("bin/$toolset/release*/a.exe")
72
73 # Test that free properties do not matter. We really do not want <cxxflags>
74 # property in build request to affect alternative selection.
75 t.write("jamfile.jam", """
76 exe a : a_empty.cpp : <variant>debug <define>FOO <include>BAR ;
77 exe a : a.cpp : <variant>release ;
78 """)
79
80 t.rm("bin/$toolset/release/a.exe")
81 t.rm("bin/$toolset/release/*/a.exe")
82 t.run_build_system(["release", "define=FOO"])
83 t.expect_addition("bin/$toolset/release*/a.exe")
84
85 # Test that ambiguity is reported correctly.
86 t.write("jamfile.jam", """\
87 exe a : a_empty.cpp ;
88 exe a : a.cpp ;
89 """)
90 t.run_build_system(["--no-error-backtrace"], status=None)
91 t.expect_output_lines("error: No best alternative for ./a")
92
93 # Another ambiguity test: two matches properties in one alternative are neither
94 # better nor worse than a single one in another alternative.
95 t.write("jamfile.jam", """\
96 exe a : a_empty.cpp : <optimization>off <profiling>off ;
97 exe a : a.cpp : <debug-symbols>on ;
98 """)
99
100 t.run_build_system(["--no-error-backtrace"], status=None)
101 t.expect_output_lines("error: No best alternative for ./a")
102 t.rm("bin")
103
104 # Test that we can have alternative without sources.
105 t.write("jamfile.jam", """\
106 alias specific-sources ;
107 import feature ;
108 feature.extend os : MAGIC ;
109 alias specific-sources : b.cpp : <os>MAGIC ;
110 exe a : a.cpp specific-sources ;
111 """)
112 t.run_build_system()
113 t.expect_addition("bin/$toolset/debug*/a.exe")
114 t.rm("bin")
115
116 # Test that subfeatures are expanded in alternatives
117 # and that unknown subfeatures fail to match instead of
118 # causing errors.
119 t.write("jamfile.jam", """\
120 import feature : feature subfeature ;
121 feature X : off on : propagated ;
122 subfeature X on : version : 1 : propagated ;
123 exe a : a.cpp : <X>on-1 ;
124 exe a : a_empty.cpp ;
125 exe a : a_empty.cpp : <X>on-2 ;
126 """)
127 t.run_build_system(["X=on-1"])
128
129 t.cleanup()