]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/unused.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / unused.py
1 #!/usr/bin/python
2
3 # Copyright 2003 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 # Test that unused sources are at least reported.
9
10 import BoostBuild
11
12 t = BoostBuild.Tester(["-d+2"], use_test_config=False)
13
14 t.write("a.cpp", "int main() {}\n")
15 t.write("b.cpp", "\n")
16 t.write("b.xyz", "")
17 t.write("jamroot.jam", """\
18 import "class" : new ;
19 import modules ;
20 import project ;
21 import targets ;
22 import type ;
23 import virtual-target ;
24
25 type.register X : xyz ;
26
27 class test-target-class : basic-target
28 {
29 rule construct ( name : source-targets * : property-set )
30 {
31 local result = [ property-set.empty ] ;
32 if ! [ modules.peek : GENERATE_NOTHING ]
33 {
34 result += [ virtual-target.from-file b.xyz : . : $(self.project) ] ;
35 if ! [ modules.peek : GENERATE_ONLY_UNUSABLE ]
36 {
37 result += [ virtual-target.from-file b.cpp : . : $(self.project)
38 ] ;
39 }
40 }
41 return $(result) ;
42 }
43
44 rule compute-usage-requirements ( rproperties : targets * )
45 {
46 return [ property-set.create <define>FOO ] ;
47 }
48 }
49
50 rule make-b-main-target
51 {
52 local project = [ project.current ] ;
53 targets.main-target-alternative [ new test-target-class b : $(project) ] ;
54 }
55
56 exe a : a.cpp b c ;
57 make-b-main-target ;
58 alias c ; # Expands to nothing, intentionally.
59 """)
60
61 t.run_build_system()
62
63 # The second invocation should do nothing, and produce no warning. The previous
64 # invocation might have printed executed actions and other things, so it is not
65 # easy to check if a warning was issued or not.
66 t.run_build_system(stdout="")
67
68 t.run_build_system(["-sGENERATE_ONLY_UNUSABLE=1"], stdout="")
69
70 # Check that even if main target generates nothing, its usage requirements are
71 # still propagated to dependants.
72 t.write("a.cpp", """\
73 #ifndef FOO
74 #error We refuse to compile without FOO being defined!
75 We_refuse_to_compile_without_FOO_being_defined
76 #endif
77 int main() {}
78 """)
79 t.run_build_system(["-sGENERATE_NOTHING=1"])
80
81 t.cleanup()