Ignore:
Timestamp:
Dec 7, 2012, 4:34:58 PM (7 years ago)
Author:
cal@…
Message:

active_variants PortGroup 1.1: Do not require the user to put require_active_variants in a pre-configure block

File:
1 copied

Legend:

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

    r100297 r100298  
    3131#
    3232# Usage:
    33 # PortGroup       active_variants 1.0
     33# PortGroup       active_variants 1.1
    3434# if {[catch {set result [active_variants $name $required $forbidden]}]} {
    3535#   if {$result} {
     
    7070# If all you want to do is bail out when the condition isn't fulfilled, there's
    7171# a convience wrapper available. If the condition isn't met it will print an
    72 # error message and exit. This will also error out, if the port $name isn't
    73 # active, so you should probably not be using this before configure phase.
     72# error message and exit in a pre-configure phase. This can't be run any
     73# earlier, because not all dependency types are installed before configure
     74# phase. Previous versions of this PortGroup required you to manually put
     75# require_active_variants in a pre-configure block. This is now done
     76# automatically.
    7477#
    7578# require_active_variants $name $required $forbidden
    7679#
     80# ChangeLog:
     81#  v1.1:
     82#   - require_active_variants no longer needs to be used in a pre-configure
     83#     phase manually, because it automatically wraps itself in pre-configure.
    7784
    7885proc active_variants {name required {forbidden {}}} {
     
    132139
    133140proc require_active_variants {name required {forbidden {}}} {
    134         if {[catch {set result [active_variants $name $required $forbidden]}] != 0} {
    135                 error "$name is required, but not active."
    136         }
    137         if {!$result} {
    138                 set str_required ""
    139                 if {[llength $required] > 0} {
    140                         set str_required "with +[join $required +]"
     141        pre-configure {
     142                if {[catch {set result [active_variants $name $required $forbidden]}] != 0} {
     143                        error "$name is required, but not active."
    141144                }
    142                 set str_forbidden ""
    143                 if {[llength $forbidden] > 0} {
    144                         set str_forbidden "without +[join $forbidden +]"
     145                if {!$result} {
     146                        set str_required ""
     147                        if {[llength $required] > 0} {
     148                                set str_required "with +[join $required +]"
     149                        }
     150                        set str_forbidden ""
     151                        if {[llength $forbidden] > 0} {
     152                                set str_forbidden "without +[join $forbidden +]"
     153                        }
     154                        set str_combine ""
     155                        if {$str_required != "" && $str_forbidden != ""} {
     156                                set str_combine " and "
     157                        }
     158                        error "$name must be installed ${str_required}${str_combine}${str_forbidden}."
    145159                }
    146                 set str_combine ""
    147                 if {$str_required != "" && $str_forbidden != ""} {
    148                         set str_combine " and "
    149                 }
    150                 error "$name must be installed ${str_required}${str_combine}${str_forbidden}."
    151160        }
    152161}
Note: See TracChangeset for help on using the changeset viewer.