Ignore:
Timestamp:
Jun 8, 2013, 1:09:13 AM (6 years ago)
Author:
cal@…
Message:

active_variants: rename variables to more intuitive names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/_resources/port1.0/group/active_variants-1.1.tcl

    r106768 r106779  
    3232# Usage:
    3333# PortGroup       active_variants 1.1
    34 # if {![catch {set result [active_variants $name $required $forbidden]}]} {
     34# if {![catch {set result [active_variants $depspec $required $forbidden]}]} {
    3535#   if {$result} {
    36 #     # code to be executed if $name is active with at least all variants in
     36#     # code to be executed if $depspec is active with at least all variants in
    3737#     # $required and none from $forbidden
    3838#   } else {
    39 #     # code to be executed if $name is active, but either not with all
     39#     # code to be executed if $depspec is active, but either not with all
    4040#     # variants in $required or any variant in $forbidden
    4141#   }
    4242# } else {
    43 #   # code to be executed if $name isn't active
     43#   # code to be executed if $depspec isn't active
    4444# }
    4545#
    4646# where
    47 #  $name
     47#  $depspec
    4848#    is the name of the port you're trying to check (required), which can be
    4949#    specified as either just the port, or via "(bin:lib:path):FOO:port"
     
    6262# checking in pre-configure of a port and the checked port is a dependency),
    6363# this can be simplified to:
    64 # if {[active_variants $name $required $forbidden]} {
    65 #   # code to be run if $name is active with all from $required and none from
     64# if {[active_variants $depspec $required $forbidden]} {
     65#   # code to be run if $depspec is active with all from $required and none from
    6666#   # $forbidden
    6767# } else {
    68 #   # code to be run if $name is active, but either not with all variants in
     68#   # code to be run if $depspec is active, but either not with all variants in
    6969#   # $required or any variant in $forbidden
    7070# }
     
    7878# automatically.
    7979#
    80 # require_active_variants $name $required $forbidden
     80# require_active_variants $depspec $required $forbidden
    8181#
    8282# ChangeLog:
     
    8888#     variant
    8989
    90 proc active_variants {name required {forbidden {}}} {
    91         # get the port which will provide $name; this allows us to support e.g.,
     90proc active_variants {depspec required {forbidden {}}} {
     91        # get the port which will provide $depspec; this allows us to support e.g.,
    9292        # path-style dependencies. This comes from port1.0/portutil.tcl and should
    9393        # probably not be considered public API.
    94         set port [_get_dep_port $name]
    95         if {$port == ""} {
    96             ui_error "active_variants: Error: invalid port name '${name}'"
     94        set name [_get_dep_port $depspec]
     95        if {$name == ""} {
     96            ui_error "active_variants: Error: invalid port depspec '${depspec}'"
    9797            ui_error "  expecting either: port or (bin:lib:path):foo:port"
    9898            return 0
    9999        }
    100         if {$name != $port} {
    101             ui_debug "Checking $port for active variants for depspec '$name'"
     100        if {$depspec != $name} {
     101            ui_debug "Checking $name for active variants for depspec '$depspec'"
    102102        }
    103103
     
    124124
    125125        # this will throw if $name isn't active
    126         set installed [lindex [registry_active $port] 0]
     126        set installed [lindex [registry_active $name] 0]
    127127
    128128        # In $installed there are in order: name, version, revision, variants,
     
    169169set _require_active_variants_list [list]
    170170
    171 proc require_active_variants {name required {forbidden {}}} {
     171proc require_active_variants {depspec required {forbidden {}}} {
    172172        global _require_active_variants_list
    173         lappend _require_active_variants_list [list $name $required $forbidden]
     173        lappend _require_active_variants_list [list $depspec $required $forbidden]
    174174}
    175175
     
    179179        global _require_active_variants_list
    180180        foreach _require_active_variant $_require_active_variants_list {
    181                 set name [lindex $_require_active_variant 0]
    182                 set port [_get_dep_port $name]
     181                set depspec [lindex $_require_active_variant 0]
     182                set name [_get_dep_port $depspec]
    183183                set required [lindex $_require_active_variant 1]
    184184                set forbidden [lindex $_require_active_variant 2]
    185                 if {[catch {set result [active_variants $name $required $forbidden]}] != 0} {
    186                         error "${port} is required, but not active."
     185                if {[catch {set result [active_variants $depspec $required $forbidden]}] != 0} {
     186                        error "${name} is required, but not active."
    187187                }
    188188                if {!$result} {
     
    199199                                set str_combine " and "
    200200                        }
    201                         error "${port} must be installed ${str_required}${str_combine}${str_forbidden}."
     201                        error "${name} must be installed ${str_required}${str_combine}${str_forbidden}."
    202202                }
    203203        }
Note: See TracChangeset for help on using the changeset viewer.