]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/indirect_conditional.py
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)
11 t
= BoostBuild
.Tester(use_test_config
=False)
13 t
.write("jamroot.jam", """\
14 exe a1 : a1.cpp : <conditional>@a1-rule ;
15 rule a1-rule ( properties * )
17 if <variant>debug in $(properties)
23 exe a2 : a2.cpp : <conditional>@$(__name__).a2-rule
24 <variant>debug:<optimization>speed ;
25 rule a2-rule ( properties * )
27 if <optimization>speed in $(properties)
34 <conditional>@$(__name__).a3-rule-1
35 <conditional>@$(__name__).a3-rule-2 ;
36 rule a3-rule-1 ( properties * )
38 if <optimization>speed in $(properties)
43 rule a3-rule-2 ( properties * )
45 if <variant>debug in $(properties)
47 return <optimization>speed ;
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")
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")
65 """Tests that paths etc. are handled correctly when an indirect
66 conditional is inherited by a subproject."""
67 t
= BoostBuild
.Tester(use_test_config
=False)
68 t
.write("Jamroot.jam", """
73 project : requirements <conditional>@c1 ;
74 build-project subdir ;
75 feature.feature myrule : : free ;
76 rule c1 ( properties * )
78 return <dependency>d1 <include>include <myrule>@parent-generate ;
80 rule parent-generate ( project name : property-set : sources * )
84 rule my-generate ( project name : property-set : sources * )
86 local r = [ $(property-set).get <myrule> ] ;
87 r = [ MATCH @(.*) : $(r) ] ;
88 return [ indirect.call
89 $(r) $(project) $(name) : $(property-set) : $(sources) ] ;
92 t
.write("d1.cpp", "int main(){}\n")
93 t
.write("subdir/Jamfile", """
94 generate srcs : main.cpp : <generating-rule>@my-generate ;
97 t
.write("include/a.h", "")
98 t
.write("subdir/main.cpp", "#include <a.h>\nint main() {}\n")
100 t
.expect_addition("bin/$toolset/debug*/d1.obj")
101 t
.expect_addition("bin/$toolset/debug*/d1.exe")
102 t
.expect_addition("subdir/bin/$toolset/debug*/main.obj")
103 t
.expect_addition("subdir/bin/$toolset/debug*/main.exe")
104 t
.expect_nothing_more()
107 def test_glob_in_indirect_conditional():
109 Regression test: project-rules.glob rule run from inside an indirect
110 conditional should report an error as it depends on the 'currently loaded
111 project' concept and indirect conditional rules get called only after all
112 the project modules have already finished loading.
115 t
= BoostBuild
.Tester(use_test_config
=False)
117 t
.write("jamroot.jam", """\
118 use-project /library-example/foo : util/foo ;
121 t
.write("app/app.cpp", "int main() {}\n");
122 t
.write("app/jamfile.jam", "exe app : app.cpp /library-example/foo//bar ;")
123 t
.write("util/foo/bar.cpp", """\
125 __declspec(dllexport)
129 t
.write("util/foo/jamfile.jam", """\
130 rule print-my-sources ( properties * )
133 ECHO [ glob *.cpp ] ;
135 lib bar : bar.cpp : <conditional>@print-my-sources ;
138 t
.run_build_system(status
=1)
139 t
.expect_output_lines(["My sources:", "bar.cpp"], False)
140 t
.expect_output_lines("error: Reference to the project currently being "
141 "loaded requested when there was no project module being loaded.")
148 test_glob_in_indirect_conditional()