Skip to content

Commit a15c7c7

Browse files
paolopasgrafikrobot
authored andcommitted
Fixed feature.minimize call with unexpanded properties.
* fixed feature.minimize precondition check, test case added into __test__ rule * optimized feature.add-defaults precondition check, test case added into __test__ rule fixes #573
1 parent 9e05d5e commit a15c7c7

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

doc/src/history.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
-- _Paolo Pastori_
3333
* Fix python linking to missing libutil.
3434
-- _Paolo Pastori_
35+
* Fix properties minimization during target configuration.
36+
-- _Paolo Pastori_
3537

3638
== Version 5.4.2
3739

src/build/ac.jam

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ class ac-library : basic-target
253253
[ $(property-set).raw ] ] ;
254254
relevant = [ property.select $(relevant) <link> :
255255
[ $(property-set).raw ] ] ;
256-
local min = [ property.as-path [ SORT [ feature.minimize $(relevant) ] ] ] ;
256+
# NOTE: properties returned by feature.minimize are unexpanded (no grist).
257+
local sorted = [ SORT [ feature.minimize $(relevant) ] ] ;
258+
local min = [ property.as-path $(sorted) : dont-minimize ] ;
257259

258260
local key = ac-library-$(name)-$(relevant:J=-) ;
259261
local lookup = [ config-cache.get $(key) ] ;

src/build/configure.jam

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ rule try-build ( targets * : ps : what : retry ? )
193193
local cache-name = $(what) $(cache-props) ;
194194
cache-name = $(cache-name:J=-) ;
195195
local value = [ config-cache.get $(cache-name) ] ;
196-
local cache-min = [ property.as-path [ SORT [ feature.minimize $(cache-props) ] ] ] ;
196+
# NOTE: properties returned by feature.minimize are unexpanded (no grist).
197+
local cache-sorted = [ SORT [ feature.minimize $(cache-props) ] ] ;
198+
local cache-min = [ property.as-path $(cache-sorted) : dont-minimize ] ;
197199

198200
local result ;
199201
local jam-targets ;
@@ -269,7 +271,9 @@ rule try-find-build ( ps : what : * )
269271
local cache-name = $(what) $($(args)[1]) $(cache-props) ;
270272
cache-name = $(cache-name:J=-) ;
271273
local value = [ config-cache.get $(cache-name) ] ;
272-
local cache-min = [ property.as-path [ SORT [ feature.minimize $(cache-props) ] ] ] ;
274+
# NOTE: properties returned by feature.minimize are unexpanded (no grist).
275+
local cache-sorted = [ SORT [ feature.minimize $(cache-props) ] ] ;
276+
local cache-min = [ property.as-path $(cache-sorted) : dont-minimize ] ;
273277

274278
local result ;
275279
local jam-targets ;

src/build/feature.jam

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ local rule move-subfeatures-to-the-end ( properties * )
925925
rule minimize ( properties * )
926926
{
927927
# Precondition checking
928-
local implicits = [ set.intersection $(p:G=) : $(p:G) ] ;
928+
local implicits = [ set.intersection $(properties:G=) : $(properties) ] ;
929929
if $(implicits)
930930
{
931931
import errors ;
@@ -1066,16 +1066,16 @@ local rule split-top-feature ( feature-plus )
10661066
#
10671067
rule add-defaults ( properties * )
10681068
{
1069-
for local v in $(properties:G=)
1069+
# Precondition checking
1070+
local implicits = [ set.intersection $(properties:G=) : $(properties) ] ;
1071+
if $(implicits)
10701072
{
1071-
if $(v) in $(properties)
1072-
{
1073-
import errors ;
1074-
errors.error add-defaults requires explicitly specified features,
1075-
but \"$(v)\" appears to be the value of an un-expanded implicit
1076-
feature ;
1077-
}
1073+
import errors ;
1074+
errors.error add-defaults requires explicitly specified features,
1075+
but \"$(implicits[1])\" appears to be the value of an un-expanded
1076+
implicit feature ;
10781077
}
1078+
10791079
local missing-top = [ set.difference $(.all-top-features) : $(properties:G) ] ;
10801080
local more = [ defaults $(missing-top) ] ;
10811081

@@ -1384,6 +1384,18 @@ rule __test__ ( )
13841384
}
13851385
catch explicitly-specified values of non-free feature <optimization> conflict ;
13861386

1387+
try ;
1388+
{
1389+
minimize debug <variant>debug ;
1390+
}
1391+
catch minimize requires an expanded property set, but \"debug\" appears to be the value of an un-expanded implicit feature ;
1392+
1393+
try ;
1394+
{
1395+
add-defaults debug <variant>debug ;
1396+
}
1397+
catch add-defaults requires explicitly specified features, but \"debug\" appears to be the value of an un-expanded implicit feature ;
1398+
13871399
try ;
13881400
{
13891401
validate-feature <foobar> ;

src/build/property.jam

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,23 @@ else
294294
}
295295

296296

297-
# Returns a path representing the given expanded property set.
297+
# Returns a path representing the given property set.
298298
#
299-
rule as-path ( properties * )
299+
rule as-path (
300+
properties *
301+
: dont-minimize ? # IF set, do not try to minimize properties,
302+
# which are likely to be unexpanded.
303+
)
300304
{
301305
local entry = .result.$(properties:J=-) ;
302306

303307
if ! $($(entry))
304308
{
305-
# Trim redundancy.
306-
properties = [ feature.minimize $(properties) ] ;
309+
if ! $(dont-minimize)
310+
{
311+
# Trim redundancy.
312+
properties = [ feature.minimize $(properties) ] ;
313+
}
307314

308315
# Sort according to path-order.
309316
properties = [ sequence.insertion-sort $(properties) : path-order ] ;
@@ -831,7 +838,7 @@ class property-map
831838
if $(best[2])
832839
{
833840
import errors : error : errors.error ;
834-
properties = [ $(property-set).raw ] ;
841+
properties = [ $(property-set).raw ] ;
835842
errors.error "Ambiguous key $(properties:J= :E=)" ;
836843
}
837844
return $(best) ;

0 commit comments

Comments
 (0)