]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/build/configure.jam
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / src / build / configure.jam
1 # Copyright (c) 2010 Vladimir Prus.
2 # Copyright 2017 Rene Rivera.
3 #
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 # This module defines function to help with two main tasks:
9 #
10 # - Discovering build-time configuration for the purposes of adjusting the build
11 # process.
12 # - Reporting what is built, and how it is configured.
13
14 import "class" : new ;
15 import common ;
16 import path ;
17 import property ;
18 import property-set ;
19 import targets ;
20 import config-cache ;
21 import feature ;
22 import modules ;
23 import utility ;
24
25
26 # The configure feature allows external definition of what features are
27 # relevant for doing configuration builds. One can add additional relevant
28 # features by using:
29 #
30 # import feature ;
31 # import configure ;
32 # feature.compose <configure> : <threading> ;
33 #
34 feature.feature configure : : composite optional ;
35
36 # This is the initial set of relevant features. Note that subfeature of all
37 # relevant features are also considered relevant.
38 #
39 feature.compose <configure> :
40 <target-os> <toolset> <address-model> <architecture> <cxxstd> ;
41
42
43 rule log-summary ( )
44 {
45 }
46
47
48 .width = 30 ;
49
50 rule set-width ( width )
51 {
52 .width = $(width) ;
53 }
54
55
56 # Declare that the components specified by the parameter exist.
57 #
58 rule register-components ( components * )
59 {
60 .components += $(components) ;
61 }
62
63
64 # Declare that the components specified by the parameters will be built.
65 #
66 rule components-building ( components * )
67 {
68 .built-components += $(components) ;
69 }
70
71
72 # Report something about component configuration that the user should better
73 # know.
74 #
75 rule log-component-configuration ( component : message )
76 {
77 # FIXME: Implement per-property-set logs.
78 .component-logs.$(component) += $(message) ;
79 }
80
81
82 rule log-check-result ( result )
83 {
84 if ! $(.announced-checks)
85 {
86 ECHO "Performing configuration checks\n" ;
87 .announced-checks = 1 ;
88 }
89
90 ECHO $(result) ;
91 # FIXME: Unfinished code. Nothing seems to set .check-results at the moment.
92 #.check-results += $(result) ;
93 }
94
95
96 rule log-library-search-result ( library : result )
97 {
98 local x = [ PAD " - $(library)" : $(.width) ] ;
99 log-check-result "$(x) : $(result)" ;
100 }
101
102
103 rule print-component-configuration ( )
104 {
105 # FIXME: See what was intended with this initial assignment.
106 # local c = [ sequence.unique $(.components) ] ;
107
108 ECHO "\nComponent configuration:\n" ;
109 local c ;
110 for c in $(.components)
111 {
112 local s ;
113 if $(c) in $(.built-components)
114 {
115 s = "building" ;
116 }
117 else
118 {
119 s = "not building" ;
120 }
121 ECHO [ PAD " - $(c)" : $(.width) ] ": $(s)" ;
122 for local m in $(.component-logs.$(c))
123 {
124 ECHO " -" $(m) ;
125 }
126 }
127 ECHO ;
128 }
129
130
131 rule print-configure-checks-summary ( )
132 {
133 # FIXME: The problem with this approach is that the user sees the checks
134 # summary when all checks are done, and has no progress reporting while the
135 # checks are being executed.
136 if $(.check-results)
137 {
138 ECHO "Configuration checks summary\n" ;
139 for local r in $(.check-results)
140 {
141 ECHO $(r) ;
142 }
143 ECHO ;
144 }
145 }
146
147 # Attempts to build a set of virtual targets
148 rule try-build ( targets * : ps : what : retry ? )
149 {
150 local cache-name = $(what) [ $(ps).raw ] ;
151 cache-name = $(cache-name:J=-) ;
152 local value = [ config-cache.get $(cache-name) ] ;
153
154 local result ;
155 local jam-targets ;
156
157 for local t in $(targets)
158 {
159 jam-targets += [ $(t).actualize ] ;
160 }
161
162 if $(value)
163 {
164 local x = [ PAD " - $(what)" : $(.width) ] ;
165 if $(value) = true
166 {
167 .$(what)-supported.$(ps) = yes ;
168 result = true ;
169 log-check-result "$(x) : yes (cached)" ;
170 }
171 else
172 {
173 log-check-result "$(x) : no (cached)" ;
174 }
175 }
176 else if ! UPDATE_NOW in [ RULENAMES ]
177 {
178 # Cannot determine. Assume existance.
179 }
180 else
181 {
182 local x = [ PAD " - $(what)" : $(.width) ] ;
183 if [ UPDATE_NOW $(jam-targets) :
184 $(.log-fd) : ignore-minus-n : ignore-minus-q ]
185 {
186 .$(what)-supported.$(ps) = yes ;
187 result = true ;
188 log-check-result "$(x) : yes" ;
189 }
190 else
191 {
192 log-check-result "$(x) : no" ;
193 }
194 }
195 if ! $(value)
196 {
197 if $(result)
198 {
199 config-cache.set $(cache-name) : true ;
200 }
201 else
202 {
203 config-cache.set $(cache-name) : false ;
204 }
205 }
206 return $(result) ;
207 }
208
209 # Attempt to build a metatarget named by 'metatarget-reference'
210 # in context of 'project' with properties 'ps'.
211 # Returns non-empty value if build is OK.
212 rule builds-raw ( metatarget-reference : project : ps : what : retry ? )
213 {
214 local result ;
215
216 if ! $(retry) && ! $(.$(what)-tested.$(ps))
217 {
218 .$(what)-tested.$(ps) = true ;
219
220 local targets = [ targets.generate-from-reference
221 $(metatarget-reference) : $(project) : $(ps) ] ;
222
223 result = [ try-build $(targets[2-]) : $(ps) : $(what) : $(retry) ] ;
224 .$(what)-supported.$(ps) = $(result) ;
225
226 return $(result) ;
227
228 }
229 else
230 {
231 return $(.$(what)-supported.$(ps)) ;
232 }
233 }
234
235 local rule get-relevant-features ( )
236 {
237 local relevant = [ feature.expand <configure> ] ;
238 local result = ;
239 for local f in $(relevant)
240 {
241 if $(f) != <configure>
242 {
243 local sub = [ modules.peek feature : $(f).subfeatures ] ;
244 local name = [ utility.ungrist $(f) ] ;
245 result += $(f) <$(name)-$(sub)> ;
246 }
247 }
248 return $(result) ;
249 }
250
251 rule builds ( metatarget-reference : properties * : what ? : retry ? )
252 {
253 local toolset-subfeatures = [ modules.peek feature : <toolset>.subfeatures ] ;
254 toolset-subfeatures = <toolset-$(toolset-subfeatures)> ;
255 # FIXME: This should not be hardcoded. Other checks might want to consider a
256 # different set of features as relevant.
257 local relevant = [ property.select [ get-relevant-features ] : $(properties) ] ;
258 local ps = [ property-set.create $(relevant) ] ;
259 local t = [ targets.current ] ;
260 local p = [ $(t).project ] ;
261
262 if ! $(what)
263 {
264 local resolved = [ targets.resolve-reference $(metatarget-reference) : $(p) ] ;
265 local name = [ $(resolved[1]).name ] ;
266 what = "$(name) builds" ;
267 }
268
269 return [ builds-raw $(metatarget-reference) : $(p) : $(ps) : $(what) :
270 $(retry) ] ;
271 }
272
273
274 # Called by Boost.Build startup code to specify the file to receive the
275 # configuration check results. Should never be called by user code.
276 #
277 rule set-log-file ( log-file )
278 {
279 path.makedirs [ path.parent $(log-file) ] ;
280 .log-fd = [ FILE_OPEN $(log-file) : "w" ] ;
281 }
282
283
284 # Frontend rules
285
286 class check-target-builds-worker
287 {
288 import configure ;
289 import property-set ;
290 import targets ;
291 import property ;
292
293 rule __init__ ( target message ? : true-properties * : false-properties * )
294 {
295 self.target = $(target) ;
296 self.message = $(message) ;
297 self.true-properties = $(true-properties) ;
298 self.false-properties = $(false-properties) ;
299 }
300
301 rule check ( properties * )
302 {
303 local choosen ;
304 if [ configure.builds $(self.target) : $(properties) : $(self.message) ]
305 {
306 choosen = $(self.true-properties) ;
307 }
308 else
309 {
310 choosen = $(self.false-properties) ;
311 }
312 return [ property.evaluate-conditionals-in-context $(choosen) :
313 $(properties) ] ;
314 }
315 }
316
317
318 rule check-target-builds ( target message ? : true-properties * :
319 false-properties * )
320 {
321 local instance = [ new check-target-builds-worker $(target) $(message) :
322 $(true-properties) : $(false-properties) ] ;
323 return <conditional>@$(instance).check ;
324 }
325
326
327 IMPORT $(__name__) : check-target-builds : : check-target-builds ;