Ticket #11920: variant_registry.3.patch

File variant_registry.3.patch, 6.1 KB (added by gwhitneycom1@…, 18 years ago)

update patch to r25303

  • src/port1.0/portactivate.tcl

     
    4545} else {
    4646        target_requires ${com.apple.activate} main fetch extract checksum patch configure build destroot install
    4747}
    48 target_prerun ${com.apple.activate} activate_start
    4948
    5049set_ui_prefix
    5150
    52 proc activate_start {args} {
    53         global UI_PREFIX portname portversion portrevision variations portvariants
    54    
    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 registry
    61                 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 
    6951proc activate_main {args} {
    7052        global portname portversion portrevision portvariants user_options
    7153        registry_activate $portname ${portversion}_${portrevision}${portvariants} [array get user_options]
  • src/port1.0/portinstall.tcl

     
    4848
    4949proc install_start {args} {
    5050        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 registry
    58                 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 
    6551        ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s %s_%s%s"] $portname $portversion $portrevision $portvariants]"
    6652}
    6753
  • src/port1.0/portutil.tcl

     
    10191019            set result [catch {[ditem_key $ditem init] $name} errstr]
    10201020        }
    10211021       
    1022         if { ![info exists portvariants] } {
    1023                 set portvariants ""
    1024                 set vlist [lsort -ascii [array names variations]]
    1025 
    1026                 # Put together variants in the form +foo+bar for the registry
    1027                 foreach v $vlist {
    1028                         if { ![string equal $v [option os.platform]] && ![string equal $v [option os.arch]] } {
    1029                                 set portvariants "${portvariants}+${v}"
    1030                         }
    1031                 }
    1032         }
    1033 
    10341022        if {$result == 0} {
    10351023                # Skip the step if required and explain why through ui_debug.
    10361024                # 1st case: the step was already done (as mentioned in the state file)
     
    10731061                                # Say we're skipping.
    10741062                                set skipped 1
    10751063                               
    1076                                 ui_debug "Skipping $name ($portname) since this port is already active"
     1064                                ui_msg "Skipping $name ($portname $portvariants) since this port is already active"
    10771065                        }
    10781066                       
    10791067                }
     
    13941382    return 0
    13951383}
    13961384
     1385# Given a list of variant specifications, return a canonical string form
     1386# for the registry.
     1387    # The strategy is as follows: regardless of how some collection of variants
     1388    # was turned on or off, a particular instance of the port is uniquely
     1389    # characterized by the set of variants that are *on*. Thus, record those
     1390    # variants in a string in a standard order as +var1+var2 etc.
     1391    # We can skip the platform and architecture since those are always
     1392    # requested.  XXX: Is that really true? What if the user explicitly
     1393    # overrides the platform and architecture variants? Will the registry get
     1394    # bollixed? It would seem safer to me to just leave in all the variants that
     1395    # are on, but for now I'm just leaving the skipping code as it was in the
     1396    # previous version.
     1397proc canonicalize_variants {variants} {
     1398    array set vara $variants
     1399    set result ""
     1400    set vlist [lsort -ascii [array names vara]]
     1401    foreach v $vlist {
     1402            if { $vara($v) == "+"
     1403                 && ![string equal $v [option os.platform]]
     1404                 && ![string equal $v [option os.arch]]} {
     1405                    set result "${result}+${v}"
     1406            }
     1407    }
     1408    return $result
     1409}
     1410
    13971411proc eval_variants {variations} {
    1398     global all_variants ports_force PortInfo
     1412    global all_variants ports_force PortInfo portvariants
    13991413    set dlist $all_variants
    14001414    upvar $variations upvariations
    14011415    set chosen [choose_variants $dlist upvariations]
     
    14271441    if {[llength $dlist] > 0} {
    14281442                return 1
    14291443    }
    1430    
     1444
     1445    # Now compute the true active array of variants. Note we do not
     1446    # change upvariations any further, since that represents the
     1447    # requested list of variations; but the registry for consistency
     1448    # must encode the actual list of variants evaluated, however that
     1449    # came to pass (dependencies, defaults, etc.) While we're at it,
     1450    # it's convenient to check for inconsistent requests for
     1451    # variations, namely foo +requirer -required where the 'requirer'
     1452    # variant requires the 'required' one.
     1453    array set activevariants [list]
     1454    foreach dvar $newlist {
     1455            set thevar [ditem_key $dvar provides]
     1456            if {[info exists upvariations($thevar)]
     1457                && $upvariations($thevar) == "-"} {
     1458                    set chosenlist ""
     1459                    foreach choice $chosen {
     1460                            set othervar [ditem_key $choice provides]
     1461                            set chosenlist "${chosenlist} +${othervar}"
     1462                    }
     1463                    ui_error "Inconsistent variant specification: $portname variant +$thevar is required by at least one of $chosenlist, but specified -$thevar"
     1464                    return 1
     1465            }
     1466            set activevariants($thevar) "+"
     1467    }
     1468
     1469    # Record a canonical variant string, used e.g. in accessing the registry
     1470    set portvariants [canonicalize_variants [array get activevariants]]
     1471
     1472    # XXX: I suspect it would actually work better in the following
     1473    # block to record the activevariants in the statefile rather than
     1474    # the upvariations, since as far as I can see different sets of
     1475    # upvariations which amount to the same activevariants in the end
     1476    # can share all aspects of the build. But I'm leaving this alone
     1477    # for the time being, so that someone with more extensive
     1478    # experience can examine the idea before putting it into
     1479    # action. -- GlenWhitney
     1480
    14311481    return 0
    14321482}
    14331483