1 # Copyright (c) 2010 Vladimir Prus.
2 # Copyright 2017 Rene Rivera.
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)
8 # This module defines function to help with two main tasks:
10 # - Discovering build-time configuration for the purposes of adjusting the build
12 # - Reporting what is built, and how it is configured.
14 import "class" : new ;
26 # The configure feature allows external definition of what features are
27 # relevant for doing configuration builds. One can add additional relevant
32 # feature.compose <configure> : <threading> ;
34 feature.feature configure : : composite optional ;
36 # This is the initial set of relevant features. Note that subfeature of all
37 # relevant features are also considered relevant.
39 feature.compose <configure> :
40 <target-os> <toolset> <address-model> <architecture> <cxxstd> ;
50 rule set-width ( width )
56 # Declare that the components specified by the parameter exist.
58 rule register-components ( components * )
60 .components += $(components) ;
64 # Declare that the components specified by the parameters will be built.
66 rule components-building ( components * )
68 .built-components += $(components) ;
72 # Report something about component configuration that the user should better
75 rule log-component-configuration ( component : message )
77 # FIXME: Implement per-property-set logs.
78 .component-logs.$(component) += $(message) ;
82 rule log-check-result ( result )
84 if ! $(.announced-checks)
86 ECHO "Performing configuration checks\n" ;
87 .announced-checks = 1 ;
91 # FIXME: Unfinished code. Nothing seems to set .check-results at the moment.
92 #.check-results += $(result) ;
96 rule log-library-search-result ( library : result )
98 local x = [ PAD " - $(library)" : $(.width) ] ;
99 log-check-result "$(x) : $(result)" ;
103 rule print-component-configuration ( )
105 # FIXME: See what was intended with this initial assignment.
106 # local c = [ sequence.unique $(.components) ] ;
108 ECHO "\nComponent configuration:\n" ;
110 for c in $(.components)
113 if $(c) in $(.built-components)
121 ECHO [ PAD " - $(c)" : $(.width) ] ": $(s)" ;
122 for local m in $(.component-logs.$(c))
131 rule print-configure-checks-summary ( )
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.
138 ECHO "Configuration checks summary\n" ;
139 for local r in $(.check-results)
147 # Attempts to build a set of virtual targets
148 rule try-build ( targets * : ps : what : retry ? )
150 local cache-name = $(what) [ $(ps).raw ] ;
151 cache-name = $(cache-name:J=-) ;
152 local value = [ config-cache.get $(cache-name) ] ;
157 for local t in $(targets)
159 jam-targets += [ $(t).actualize ] ;
164 local x = [ PAD " - $(what)" : $(.width) ] ;
167 .$(what)-supported.$(ps) = yes ;
169 log-check-result "$(x) : yes (cached)" ;
173 log-check-result "$(x) : no (cached)" ;
176 else if ! UPDATE_NOW in [ RULENAMES ]
178 # Cannot determine. Assume existance.
182 local x = [ PAD " - $(what)" : $(.width) ] ;
183 if [ UPDATE_NOW $(jam-targets) :
184 $(.log-fd) : ignore-minus-n : ignore-minus-q ]
186 .$(what)-supported.$(ps) = yes ;
188 log-check-result "$(x) : yes" ;
192 log-check-result "$(x) : no" ;
199 config-cache.set $(cache-name) : true ;
203 config-cache.set $(cache-name) : false ;
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 ? )
216 if ! $(retry) && ! $(.$(what)-tested.$(ps))
218 .$(what)-tested.$(ps) = true ;
220 local targets = [ targets.generate-from-reference
221 $(metatarget-reference) : $(project) : $(ps) ] ;
223 result = [ try-build $(targets[2-]) : $(ps) : $(what) : $(retry) ] ;
224 .$(what)-supported.$(ps) = $(result) ;
231 return $(.$(what)-supported.$(ps)) ;
235 local rule get-relevant-features ( )
237 local relevant = [ feature.expand <configure> ] ;
239 for local f in $(relevant)
241 if $(f) != <configure>
243 local sub = [ modules.peek feature : $(f).subfeatures ] ;
244 local name = [ utility.ungrist $(f) ] ;
245 result += $(f) <$(name)-$(sub)> ;
251 rule builds ( metatarget-reference : properties * : what ? : retry ? )
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 ] ;
264 local resolved = [ targets.resolve-reference $(metatarget-reference) : $(p) ] ;
265 local name = [ $(resolved[1]).name ] ;
266 what = "$(name) builds" ;
269 return [ builds-raw $(metatarget-reference) : $(p) : $(ps) : $(what) :
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.
277 rule set-log-file ( log-file )
279 path.makedirs [ path.parent $(log-file) ] ;
280 .log-fd = [ FILE_OPEN $(log-file) : "w" ] ;
286 class check-target-builds-worker
289 import property-set ;
293 rule __init__ ( target message ? : true-properties * : false-properties * )
295 self.target = $(target) ;
296 self.message = $(message) ;
297 self.true-properties = $(true-properties) ;
298 self.false-properties = $(false-properties) ;
301 rule check ( properties * )
304 if [ configure.builds $(self.target) : $(properties) : $(self.message) ]
306 choosen = $(self.true-properties) ;
310 choosen = $(self.false-properties) ;
312 return [ property.evaluate-conditionals-in-context $(choosen) :
318 rule check-target-builds ( target message ? : true-properties * :
321 local instance = [ new check-target-builds-worker $(target) $(message) :
322 $(true-properties) : $(false-properties) ] ;
323 return <conditional>@$(instance).check ;
327 IMPORT $(__name__) : check-target-builds : : check-target-builds ;