]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/build/configure.jam
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / tools / build / src / build / configure.jam
1 # Copyright (c) 2010 Vladimir Prus.
2 # Copyright 2017-2021 Rene Ferdinand Rivera Morell
3 #
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE.txt or
6 # https://www.bfgroup.xyz/b2/LICENSE.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 indirect ;
17 import path ;
18 import project ;
19 import property ;
20 import property-set ;
21 import targets ;
22 import config-cache ;
23 import feature ;
24 import modules ;
25 import sequence ;
26 import utility ;
27 import virtual-target ;
28
29
30 rule log-summary ( )
31 {
32 }
33
34
35 .width = 30 ;
36
37 rule set-width ( width )
38 {
39 .width = $(width) ;
40 }
41
42
43 # Declare that the components specified by the parameter exist.
44 #
45 rule register-components ( components * )
46 {
47 .components += $(components) ;
48 }
49
50
51 # Declare that the components specified by the parameters will be built.
52 #
53 rule components-building ( components * )
54 {
55 .built-components += $(components) ;
56 }
57
58
59 # Report something about component configuration that the user should better
60 # know.
61 #
62 rule log-component-configuration ( component : message )
63 {
64 # FIXME: Implement per-property-set logs.
65 .component-logs.$(component) += $(message) ;
66 }
67
68
69 .variant_index = 0 ;
70 .nl = "\n" ;
71
72 .check_notes = ;
73
74 rule log-check-result ( result variant ? )
75 {
76 if ! $(.announced-checks)
77 {
78 ECHO "Performing configuration checks\n" ;
79 .announced-checks = 1 ;
80 }
81
82 if $(variant)
83 {
84 if $(.variant_index.$(variant))
85 {
86 result = "$(result) [$(.variant_index.$(variant))]" ;
87 }
88 else
89 {
90 .variant_index = [ CALC $(.variant_index) + 1 ] ;
91 .variant_index.$(variant) = $(.variant_index) ;
92 result = "$(result) [$(.variant_index.$(variant))]" ;
93 .check_notes += "[$(.variant_index.$(variant))] $(variant)" ;
94 }
95 }
96 # else
97 # {
98 # result = "$(result) [?]" ;
99 # }
100
101 ECHO $(result) ;
102 # FIXME: Unfinished code. Nothing seems to set .check-results at the moment.
103 #.check-results += $(result) ;
104 }
105
106
107 rule log-library-search-result ( library : result variant ? )
108 {
109 local x = [ PAD " - $(library)" : $(.width) ] ;
110 log-check-result "$(x) : $(result)" $(variant) ;
111 }
112
113
114 rule print-component-configuration ( )
115 {
116 # FIXME: See what was intended with this initial assignment.
117 # local c = [ sequence.unique $(.components) ] ;
118
119 ECHO "\nComponent configuration:\n" ;
120 local c ;
121 for c in $(.components)
122 {
123 local s ;
124 if $(c) in $(.built-components)
125 {
126 s = "building" ;
127 }
128 else
129 {
130 s = "not building" ;
131 }
132 ECHO [ PAD " - $(c)" : $(.width) ] ": $(s)" ;
133 for local m in $(.component-logs.$(c))
134 {
135 ECHO " -" $(m) ;
136 }
137 }
138 ECHO ;
139 }
140
141
142 rule print-configure-checks-summary ( )
143 {
144 if $(.check_notes)
145 {
146 ECHO ;
147 for local l in $(.check_notes) { ECHO $(l) ; }
148 }
149
150 # FIXME: The problem with this approach is that the user sees the checks
151 # summary when all checks are done, and has no progress reporting while the
152 # checks are being executed.
153 if $(.check-results)
154 {
155 ECHO "Configuration checks summary\n" ;
156 for local r in $(.check-results)
157 {
158 ECHO $(r) ;
159 }
160 ECHO ;
161 }
162 }
163
164 if --reconfigure in [ modules.peek : ARGV ]
165 {
166 .reconfigure = true ;
167 }
168
169 # Handle the --reconfigure option
170 rule maybe-force-rebuild ( targets * )
171 {
172 if $(.reconfigure)
173 {
174 local all-targets ;
175 for local t in $(targets)
176 {
177 all-targets += [ virtual-target.traverse $(t) ] ;
178 }
179 for local t in [ sequence.unique $(all-targets) ]
180 {
181 $(t).always ;
182 }
183 }
184 }
185
186 # Attempts to build a set of virtual targets
187 rule try-build ( targets * : ps : what : retry ? )
188 {
189 local cache-props = [ $(ps).raw ] ;
190 local cache-name = $(what) $(cache-props) ;
191 cache-name = $(cache-name:J=-) ;
192 local value = [ config-cache.get $(cache-name) ] ;
193 local cache-min = [ property.as-path [ SORT [ feature.minimize $(cache-props) ] ] ] ;
194
195 local result ;
196 local jam-targets ;
197
198 maybe-force-rebuild $(targets) ;
199
200 for local t in $(targets)
201 {
202 jam-targets += [ $(t).actualize ] ;
203 }
204
205 local x ;
206 if $(value)
207 {
208 x = [ PAD " - $(what)" : $(.width) ] ;
209 if $(value) = true
210 {
211 .$(what)-supported.$(ps) = yes ;
212 result = true ;
213 x = "$(x) : yes (cached)" ;
214 }
215 else
216 {
217 x = "$(x) : no (cached)" ;
218 }
219 }
220 else if ! UPDATE_NOW in [ RULENAMES ]
221 {
222 # Cannot determine. Assume existence.
223 }
224 else
225 {
226 x = [ PAD " - $(what)" : $(.width) ] ;
227 if [ UPDATE_NOW $(jam-targets) :
228 $(.log-fd) : ignore-minus-n : ignore-minus-q ]
229 {
230 .$(what)-supported.$(ps) = yes ;
231 result = true ;
232 x = "$(x) : yes" ;
233 }
234 else
235 {
236 x = "$(x) : no" ;
237 }
238 }
239 if $(x)
240 {
241 log-check-result "$(x)" "$(cache-min:J= )" ;
242 }
243 if ! $(value)
244 {
245 if $(result)
246 {
247 config-cache.set $(cache-name) : true ;
248 }
249 else
250 {
251 config-cache.set $(cache-name) : false ;
252 }
253 }
254 return $(result) ;
255 }
256
257 # Attempts to build several sets of virtual targets. Returns the
258 # the index of the first set that builds.
259 rule try-find-build ( ps : what : * )
260 {
261 local args = 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ;
262 # The outer layer only needs to check $(what), but we
263 # also need to check the individual elements, in case
264 # the set of targets has changed since the last build.
265 local cache-props = [ $(ps).raw ] ;
266 local cache-name = $(what) $($(args)[1]) $(cache-props) ;
267 cache-name = $(cache-name:J=-) ;
268 local value = [ config-cache.get $(cache-name) ] ;
269 local cache-min = [ property.as-path [ SORT [ feature.minimize $(cache-props) ] ] ] ;
270
271 local result ;
272 local jam-targets ;
273
274 maybe-force-rebuild $($(args)[2-]) ;
275
276 # Make sure that the targets are always actualized,
277 # even if the result is cached. This is needed to
278 # allow clean-all to find them and also to avoid
279 # unintentional behavior changes.
280 for local t in $($(args)[2-])
281 {
282 $(t).actualize ;
283 }
284
285 if $(value)
286 {
287 local none = none ; # What to show when the argument
288 local name = $(value) ;
289 if $(name) != none
290 {
291 name = [ CALC $(name) + 2 ] ;
292 }
293 local x = [ PAD " - $(what)" : $(.width) ] ;
294 local y = [ PAD $($(name)[1]) : 3 ] ;
295 result = $(value) ;
296 log-check-result "$(x) : $(y) (cached)" "$(cache-min:J= )" ;
297 }
298 else
299 {
300 local x = [ PAD " - $(what)" : $(.width) ] ;
301 for local i in $(args)
302 {
303 if ! $($(i)[1])
304 {
305 break ;
306 }
307 local jam-targets ;
308 for local t in $($(i)[2-])
309 {
310 jam-targets += [ $(t).actualize ] ;
311 }
312 if [ UPDATE_NOW $(jam-targets) :
313 $(.log-fd) : ignore-minus-n : ignore-minus-q ]
314 {
315 result = [ CALC $(i) - 2 ] ;
316 log-check-result "$(x) : $($(i)[1])" "$(cache-min:J= )" ;
317 break ;
318 }
319 }
320 if ! $(result)
321 {
322 log-check-result "$(x) : none" "$(cache-min:J= )" ;
323 result = none ;
324 }
325 }
326 if ! $(value)
327 {
328 if $(result)
329 {
330 config-cache.set $(cache-name) : $(result) ;
331 }
332 else
333 {
334 config-cache.set $(cache-name) : $(result) ;
335 }
336 }
337 if $(result) != none
338 {
339 return $(result) ;
340 }
341 }
342
343 # Attempt to build a metatarget named by 'metatarget-reference'
344 # in context of 'project' with properties 'ps'.
345 # Returns non-empty value if build is OK.
346 rule builds-raw ( metatarget-reference : project : ps : what : retry ? )
347 {
348 local result ;
349
350 if ! $(retry) && ! $(.$(what)-tested.$(ps))
351 {
352 .$(what)-tested.$(ps) = true ;
353
354 local targets = [ targets.generate-from-reference
355 $(metatarget-reference) : $(project) : $(ps) ] ;
356
357 result = [ try-build $(targets[2-]) : $(ps) : $(what) : $(retry) ] ;
358 .$(what)-supported.$(ps) = $(result) ;
359
360 return $(result) ;
361
362 }
363 else
364 {
365 return $(.$(what)-supported.$(ps)) ;
366 }
367 }
368
369 # Attempt to build a metatarget named by 'metatarget-reference'
370 # in context of 'project' with properties 'ps'.
371 # Returns the 1-based index of the first target
372 # that builds.
373 rule find-builds-raw ( project : ps : what : * )
374 {
375 local result ;
376 local args = 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ;
377
378 if ! $(.$(what)-tested.$(ps))
379 {
380 .$(what)-tested.$(ps) = true ;
381 local targets.$(i) what.$(i) ;
382 for local i in $(args)
383 {
384 if ! $($(i))
385 {
386 break ;
387 }
388 targets.$(i) = [ targets.generate-from-reference
389 $($(i)[1]) : $(project) : $(ps) ] ;
390 # ignore usage requirements
391 targets.$(i) = $(targets.$(i)[2-]) ;
392 if $($(i)[2])
393 {
394 what.$(i) = $($(i)[2]) ;
395 }
396 else
397 {
398 local t = [ targets.resolve-reference
399 $($(i)[1]) : $(project) ] ;
400 what.$(i) = [ $(t[1]).name ] ;
401 }
402 }
403
404 result = [ try-find-build $(ps) : $(what)
405 : $(what.4) $(targets.4)
406 : $(what.5) $(targets.5)
407 : $(what.6) $(targets.6)
408 : $(what.7) $(targets.7)
409 : $(what.8) $(targets.8)
410 : $(what.9) $(targets.9)
411 : $(what.10) $(targets.10)
412 : $(what.11) $(targets.11)
413 : $(what.12) $(targets.12)
414 : $(what.13) $(targets.13)
415 : $(what.14) $(targets.14)
416 : $(what.15) $(targets.15)
417 : $(what.16) $(targets.16)
418 : $(what.17) $(targets.17)
419 : $(what.18) $(targets.18)
420 : $(what.19) $(targets.19) ] ;
421 .$(what)-result.$(ps) = $(result) ;
422
423 return $(result) ;
424 }
425 else
426 {
427 return $(.$(what)-result.$(ps)) ;
428 }
429 }
430
431 rule get-relevant-features ( properties * )
432 {
433 local ps-full = [ property-set.create $(properties) ] ;
434 local ps-base = [ property-set.create [ $(ps-full).base ] ] ;
435 local ps-min = [ feature.expand-subfeatures [ feature.minimize
436 [ $(ps-base).raw ] ] ] ;
437 local ps-relevant = [ property-set.create $(ps-min) ] ;
438
439 return [ $(ps-relevant).raw ] ;
440 }
441
442 rule builds ( metatarget-reference : properties * : what ? : retry ? )
443 {
444 local relevant = [ get-relevant-features $(properties) ] ;
445 local ps = [ property-set.create $(relevant) ] ;
446 local t = [ targets.current ] ;
447 local p = [ $(t).project ] ;
448
449 if ! $(what)
450 {
451 local resolved = [ targets.resolve-reference $(metatarget-reference) : $(p) ] ;
452 local name = [ $(resolved[1]).name ] ;
453 what = "$(name) builds" ;
454 }
455
456 return [ builds-raw $(metatarget-reference) : $(p) : $(ps) : $(what) :
457 $(retry) ] ;
458 }
459
460 rule find-builds ( what : properties * : * )
461 {
462 local relevant = [ get-relevant-features $(properties) ] ;
463 local ps = [ property-set.create $(relevant) ] ;
464 local t = [ targets.current ] ;
465 local p = [ $(t).project ] ;
466
467 return [ find-builds-raw $(p) : $(ps) : $(what) :
468 $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) :
469 $(10) : $(11) : $(12) : $(13) : $(14) : $(15) :
470 $(16) : $(17) : $(18) ] ;
471 }
472
473
474 # Called by B2 startup code to specify the file to receive the
475 # configuration check results. Should never be called by user code.
476 #
477 rule set-log-file ( log-file )
478 {
479 path.makedirs [ path.parent $(log-file) ] ;
480 .log-fd = [ FILE_OPEN [ path.native $(log-file) ] : "w" ] ;
481 if ! $(.log-fd)
482 {
483 ECHO "warning:" failed to open log file $(log-file) for writing ;
484 }
485 }
486
487
488 # Frontend rules
489
490 class check-target-builds-worker
491 {
492 import configure ;
493 import property-set ;
494 import targets ;
495 import project ;
496 import property ;
497
498 rule __init__ ( target message ? : true-properties * : false-properties * )
499 {
500 local project = [ project.current ] ;
501 self.target = $(target) ;
502 self.message = $(message) ;
503 self.true-properties =
504 [ configure.translate-properties $(true-properties) : $(project) ] ;
505 self.false-properties =
506 [ configure.translate-properties $(false-properties) : $(project) ] ;
507 }
508
509 rule check ( properties * )
510 {
511 local choosen ;
512 if [ configure.builds $(self.target) : $(properties) : $(self.message) ]
513 {
514 choosen = $(self.true-properties) ;
515 }
516 else
517 {
518 choosen = $(self.false-properties) ;
519 }
520 return [ property.evaluate-conditionals-in-context $(choosen) :
521 $(properties) ] ;
522 }
523 }
524
525 class configure-choose-worker
526 {
527 import configure ;
528 import property ;
529 import project ;
530 rule __init__ ( message : * )
531 {
532 local project = [ project.current ] ;
533 self.message = $(message) ;
534 for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
535 {
536 local name = [ CALC $(i) - 1 ] ;
537 self.targets.$(name) = $($(i)[1]) ;
538 if ! $($(i)[2]:G) # Check whether the second argument is a property
539 {
540 self.what.$(name) = $($(i)[2]) ;
541 self.props.$(name) = $($(i)[3-]) ;
542 }
543 else
544 {
545 self.props.$(name) = $($(i)[2-]) ;
546 }
547 self.props.$(name) = [ configure.translate-properties
548 $(self.props.$(name)) : $(project) ] ;
549 }
550 }
551 rule all-properties ( )
552 {
553 local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ;
554 return $(self.props.$(i)) ;
555 }
556 rule check ( properties * )
557 {
558 local i = [ configure.find-builds $(self.message) : $(properties)
559 : $(self.targets.1) $(self.what.1)
560 : $(self.targets.2) $(self.what.2)
561 : $(self.targets.3) $(self.what.3)
562 : $(self.targets.4) $(self.what.4)
563 : $(self.targets.5) $(self.what.5)
564 : $(self.targets.6) $(self.what.6)
565 : $(self.targets.7) $(self.what.7)
566 : $(self.targets.8) $(self.what.8)
567 : $(self.targets.9) $(self.what.9)
568 : $(self.targets.10) $(self.what.10)
569 : $(self.targets.11) $(self.what.11)
570 : $(self.targets.12) $(self.what.12)
571 : $(self.targets.13) $(self.what.13)
572 : $(self.targets.14) $(self.what.14)
573 : $(self.targets.15) $(self.what.15)
574 : $(self.targets.16) $(self.what.16)
575 : $(self.targets.17) $(self.what.17) ] ;
576 if $(self.props.$(i))
577 {
578 return [ property.evaluate-conditionals-in-context $(self.props.$(i)) : $(properties) ] ;
579 }
580 }
581 }
582
583 rule translate-properties ( properties * : project ? )
584 {
585 if $(project) && [ $(project).location ]
586 {
587 local location = [ $(project).location ] ;
588 local m = [ $(project).project-module ] ;
589 local project-id = [ project.attribute $(m) id ] ;
590 project-id ?= [ path.root $(location) [ path.pwd ] ] ;
591 return [ property.translate $(properties)
592 : $(project-id) : $(location) : $(m) ] ;
593 }
594 else
595 {
596 return $(properties) ;
597 }
598 }
599
600 rule check-target-builds ( target message ? : true-properties * :
601 false-properties * )
602 {
603 local instance = [ new check-target-builds-worker $(target) $(message) :
604 $(true-properties) : $(false-properties) ] ;
605 local rulename = [ indirect.make check : $(instance) ] ;
606 return <conditional>@$(rulename)
607 [ property.evaluate-conditional-relevance
608 $(true-properties) $(false-properties) ] ;
609 }
610
611 # Usage:
612 # [ configure.choose "architecture"
613 # : /config//x86 x86 <architecture>x86
614 # : /config//mips mips <architecture>mips
615 # ]
616 rule choose ( message : * )
617 {
618 local instance = [ new configure-choose-worker $(message)
619 : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9)
620 : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16)
621 : $(17) : $(18) : $(19) ] ;
622 local rulename = [ indirect.make check : $(instance) ] ;
623 return <conditional>@$(rulename)
624 [ property.evaluate-conditional-relevance
625 [ $(instance).all-properties ] ] ;
626 }
627
628
629 IMPORT $(__name__) : check-target-builds : : check-target-builds ;