]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/core_dependencies.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / test / core_dependencies.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 http://www.boost.org/LICENSE_1_0.txt)
6
7 # This tests correct handling of dependencies, specifically, on generated
8 # sources, and from generated sources.
9
10 import BoostBuild
11
12 import string
13
14 t = BoostBuild.Tester(pass_toolset=0)
15
16 t.write("core-dependency-helpers", """
17 rule hdrrule
18 {
19 INCLUDES $(1) : $(2) ;
20 }
21 actions copy
22 {
23 cp $(>) $(<)
24 }
25 """)
26
27 code = """include core-dependency-helpers ;
28 DEPENDS all : a ;
29 DEPENDS a : b ;
30
31 actions create-b
32 {
33 echo '#include <foo.h>' > $(<)
34 }
35 copy a : b ;
36 create-b b ;
37 HDRRULE on b foo.h bar.h = hdrrule ;
38 HDRSCAN on b foo.h bar.h = \"#include <(.*)>\" ;
39 """
40
41 # This creates 'a' which depends on 'b', which is generated. The generated 'b'
42 # contains '#include <foo.h>' and no rules for foo.h are given. The system
43 # should error out on the first invocation.
44 t.run_build_system("-f-", stdin=code)
45 t.fail_test(string.find(t.stdout(), "...skipped a for lack of foo.h...") == -1)
46
47 t.rm('b')
48
49 # Now test that if target 'c' also depends on 'b', then it will not be built, as
50 # well.
51 t.run_build_system("-f-", stdin=code + " copy c : b ; DEPENDS c : b ; DEPENDS all : c ; ")
52 t.fail_test(string.find(t.stdout(), "...skipped c for lack of foo.h...") == -1)
53
54 t.rm('b')
55
56 # Now add a rule for creating foo.h.
57 code += """
58 actions create-foo
59 {
60 echo // > $(<)
61 }
62 create-foo foo.h ;
63 """
64 t.run_build_system("-f-", stdin=code)
65
66 # Run two times, adding explicit dependency from all to foo.h at the beginning
67 # and at the end, to make sure that foo.h is generated before 'a' in all cases.
68
69 def mk_correct_order_func(s1, s2):
70 def correct_order(s):
71 n1 = string.find(s, s1)
72 n2 = string.find(s, s2)
73 return ( n1 != -1 ) and ( n2 != -1 ) and ( n1 < n2 )
74 return correct_order
75
76 correct_order = mk_correct_order_func("create-foo", "copy a")
77
78 t.rm(["a", "b", "foo.h"])
79 t.run_build_system("-d+2 -f-", stdin=code + " DEPENDS all : foo.h ;")
80 t.fail_test(not correct_order(t.stdout()))
81
82 t.rm(["a", "b", "foo.h"])
83 t.run_build_system("-d+2 -f-", stdin=" DEPENDS all : foo.h ; " + code)
84 t.fail_test(not correct_order(t.stdout()))
85
86 # Now foo.h exists. Test include from b -> foo.h -> bar.h -> biz.h. b and foo.h
87 # already have updating actions.
88 t.rm(["a", "b"])
89 t.write("foo.h", "#include <bar.h>")
90 t.write("bar.h", "#include <biz.h>")
91 t.run_build_system("-d+2 -f-", stdin=code)
92 t.fail_test(string.find(t.stdout(), "...skipped a for lack of biz.h...") == -1)
93
94 # Add an action for biz.h.
95 code += """
96 actions create-biz
97 {
98 echo // > $(<)
99 }
100 create-biz biz.h ;
101 """
102
103 t.rm(["b"])
104 correct_order = mk_correct_order_func("create-biz", "copy a")
105 t.run_build_system("-d+2 -f-", stdin=code + " DEPENDS all : biz.h ;")
106 t.fail_test(not correct_order(t.stdout()))
107
108 t.rm(["a", "biz.h"])
109 t.run_build_system("-d+2 -f-", stdin=" DEPENDS all : biz.h ; " + code)
110 t.fail_test(not correct_order(t.stdout()))
111
112 t.write("a", "")
113
114 code="""
115 DEPENDS all : main d ;
116
117 actions copy
118 {
119 cp $(>) $(<) ;
120 }
121
122 DEPENDS main : a ;
123 copy main : a ;
124
125 INCLUDES a : <1>c ;
126
127 NOCARE <1>c ;
128 SEARCH on <1>c = . ;
129
130 actions create-c
131 {
132 echo d > $(<)
133 }
134
135 actions create-d
136 {
137 echo // > $(<)
138 }
139
140 create-c <2>c ;
141 LOCATE on <2>c = . ;
142 create-d d ;
143
144 HDRSCAN on <1>c = (.*) ;
145 HDRRULE on <1>c = hdrrule ;
146
147 rule hdrrule
148 {
149 INCLUDES $(1) : d ;
150 }
151 """
152
153 correct_order = mk_correct_order_func("create-d", "copy main")
154 t.run_build_system("-d2 -f-", stdin=code)
155 t.fail_test(not correct_order(t.stdout()))
156
157 t.cleanup()