Ticket #11920: variant_registry.2.patch
File variant_registry.2.patch, 6.3 KB (added by gwhitney@…, 18 years ago) |
---|
-
src/port1.0/portactivate.tcl
45 45 } else { 46 46 target_requires ${com.apple.activate} main fetch extract checksum patch configure build destroot install 47 47 } 48 target_prerun ${com.apple.activate} activate_start49 48 50 49 set_ui_prefix 51 50 52 proc activate_start {args} {53 global UI_PREFIX portname portversion portrevision variations portvariants54 55 if { ![info exists portvariants] } {56 set portvariants ""57 58 set vlist [lsort -ascii [array names variations]]59 60 # Put together variants in the form +foo+bar for the registry61 foreach v $vlist {62 if { ![string equal $v [option os.platform]] && ![string equal $v [option os.arch]] } {63 set portvariants "${portvariants}+${v}"64 }65 }66 }67 }68 69 51 proc activate_main {args} { 70 52 global portname portversion portrevision portvariants user_options 71 53 registry_activate $portname ${portversion}_${portrevision}${portvariants} [array get user_options] -
src/port1.0/portinstall.tcl
48 48 49 49 proc install_start {args} { 50 50 global UI_PREFIX portname portversion portrevision variations portvariants 51 52 if { ![info exists portvariants] } {53 set portvariants ""54 55 set vlist [lsort -ascii [array names variations]]56 57 # Put together variants in the form +foo+bar for the registry58 foreach v $vlist {59 if { ![string equal $v [option os.platform]] && ![string equal $v [option os.arch]] } {60 set portvariants "${portvariants}+${v}"61 }62 }63 }64 65 51 ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s %s_%s%s"] $portname $portversion $portrevision $portvariants]" 66 52 } 67 53 -
src/port1.0/portutil.tcl
990 990 set result [catch {[ditem_key $ditem init] $name} errstr] 991 991 } 992 992 993 if { ![info exists portvariants] } {994 set portvariants ""995 set vlist [lsort -ascii [array names variations]]996 997 # Put together variants in the form +foo+bar for the registry998 foreach v $vlist {999 if { ![string equal $v [option os.platform]] && ![string equal $v [option os.arch]] } {1000 set portvariants "${portvariants}+${v}"1001 }1002 }1003 }1004 1005 993 if {$result == 0} { 1006 994 # Skip the step if required and explain why through ui_debug. 1007 995 # 1st case: the step was already done (as mentioned in the state file) … … 1044 1032 # Say we're skipping. 1045 1033 set skipped 1 1046 1034 1047 ui_ debug "Skipping $name ($portname) since this port is already active"1035 ui_msg "Skipping $name ($portname $portvariants) since this port is already active" 1048 1036 } 1049 1037 1050 1038 } … … 1367 1355 return 0 1368 1356 } 1369 1357 1358 # Given a list of variant specifications, return a canonical string form 1359 # for the registry. 1360 # The strategy is as follows: regardless of how some collection of variants 1361 # was turned on or off, a particular instance of the port is uniquely 1362 # characterized by the set of variants that are *on*. Thus, record those 1363 # variants in a string in a standard order as +var1+var2 etc. 1364 # We can skip the platform and architecture since those are always 1365 # requested. XXX: Is that really true? What if the user explicitly 1366 # overrides the platform and architecture variants? Will the registry get 1367 # bollixed? It would seem safer to me to just leave in all the variants that 1368 # are on, but for now I'm just leaving the skipping code as it was in the 1369 # previous version. 1370 proc canonicalize_variants {variants} { 1371 array set vara $variants 1372 set result "" 1373 set vlist [lsort -ascii [array names vara]] 1374 foreach v $vlist { 1375 if { $vara($v) == "+" 1376 && ![string equal $v [option os.platform]] 1377 && ![string equal $v [option os.arch]]} { 1378 set result "${result}+${v}" 1379 } 1380 } 1381 return $result 1382 } 1383 1370 1384 proc eval_variants {variations target} { 1371 global all_variants ports_force PortInfo 1385 global all_variants ports_force PortInfo portvariants 1372 1386 set dlist $all_variants 1373 1387 set result 0 1374 1388 upvar $variations upvariations … … 1401 1415 if {[llength $dlist] > 0} { 1402 1416 return 1 1403 1417 } 1404 1418 1419 # Now compute the true active array of variants. Note we do not 1420 # change upvariations any further, since that represents the 1421 # requested list of variations; but the registry for consistency 1422 # must encode the actual list of variants evaluated, however that 1423 # came to pass (dependencies, defaults, etc.) While we're at it, 1424 # it's convenient to check for inconsistent requests for 1425 # variations, namely foo +requirer -required where the 'requirer' 1426 # variant requires the 'required' one. 1427 array set activevariants [list] 1428 foreach dvar $newlist { 1429 set thevar [ditem_key $dvar provides] 1430 if {[info exists upvariations($thevar)] 1431 && $upvariations($thevar) == "-"} { 1432 set chosenlist "" 1433 foreach choice $chosen { 1434 set othervar [ditem_key $choice provides] 1435 set chosenlist "${chosenlist} +${othervar}" 1436 } 1437 ui_error "Inconsistent variant specification: $portname variant +$thevar is required by at least one of $chosenlist, but specified -$thevar" 1438 return 1 1439 } 1440 set activevariants($thevar) "+" 1441 } 1442 1443 # Record a canonical variant string, used e.g. in accessing the registry 1444 set portvariants [canonicalize_variants [array get activevariants]] 1445 1446 # XXX: I suspect it would actually work better in the following 1447 # block to record the activevariants in the statefile rather than 1448 # the upvariations, since as far as I can see different sets of 1449 # upvariations which amount to the same activevariants in the end 1450 # can share all aspects of the build. But I'm leaving this alone 1451 # for the time being, so that someone with more extensive 1452 # experience can examine the idea before putting it into 1453 # action. -- GlenWhitney 1454 1405 1455 # Make sure the variations match those stored in the statefile. 1406 1456 # If they don't match, print an error indicating a 'port clean' 1407 1457 # should be performed.