]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/alternatives.py
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)
8 # Test main target alternatives.
13 t
= BoostBuild
.Tester(use_test_config
=False)
15 # Test that basic alternatives selection works.
16 t
.write("jamroot.jam", "")
18 t
.write("jamfile.jam", """
20 exe a : a.cpp : <variant>release ;
23 t
.write("a_empty.cpp", "")
25 t
.write("a.cpp", "int main() {}\n")
27 t
.run_build_system(["release"])
29 t
.expect_addition("bin/$toolset/release*/a.exe")
31 # Test that alternative selection works for ordinary properties, in particular
33 t
.write("jamroot.jam", "")
35 t
.write("jamfile.jam", """
37 feature.feature X : off on : propagated ;
39 exe a : a.cpp : <X>on ;
41 t
.write("b.cpp", "int main() {}\n")
46 t
.expect_addition("bin/$toolset/debug*/b.obj")
48 t
.run_build_system(["X=on"])
49 t
.expect_addition("bin/$toolset/debug/X-on*/a.obj")
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 ;
60 t
.expect_addition("bin/$toolset/debug*/a.exe")
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 ;
70 t
.run_build_system(["release"])
71 t
.expect_addition("bin/$toolset/release*/a.exe")
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 ;
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")
85 # Test that ambiguity is reported correctly.
86 t
.write("jamfile.jam", """\
90 t
.run_build_system(["--no-error-backtrace"], status
=None)
91 t
.expect_output_lines("error: No best alternative for ./a")
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 ;
100 t
.run_build_system(["--no-error-backtrace"], status
=None)
101 t
.expect_output_lines("error: No best alternative for ./a")
104 # Test that we can have alternative without sources.
105 t
.write("jamfile.jam", """\
106 alias specific-sources ;
108 feature.extend os : MAGIC ;
109 alias specific-sources : b.cpp : <os>MAGIC ;
110 exe a : a.cpp specific-sources ;
113 t
.expect_addition("bin/$toolset/debug*/a.exe")
116 # Test that subfeatures are expanded in alternatives
117 # and that unknown subfeatures fail to match instead of
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 ;
127 t
.run_build_system(["X=on-1"])