Ignore:
Timestamp:
Dec 7, 2012, 9:46:00 PM (7 years ago)
Author:
cal@…
Message:

active_variants 1.1: fix incorrect attempt at putting require_active_variants into pre-configure automatically

File:
1 edited

Legend:

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

    r100298 r100302  
    138138}
    139139
     140proc _variant_in_variant_list {needle haystack} {
     141        foreach variant $haystack {
     142                if {$variant == $needle} {
     143                        return 1
     144                }
     145        }
     146        return 0
     147}
     148
     149# global list holding all items the should be checked for and cause an error if
     150# not present
     151set _require_active_variants_list [list]
     152
    140153proc require_active_variants {name required {forbidden {}}} {
    141         pre-configure {
     154        global _require_active_variants_list
     155        lappend _require_active_variants_list [list $name $required $forbidden]
     156}
     157
     158# function to be called in pre-configure to check for all items added using
     159# require_active_variants
     160proc _check_require_active_variants {} {
     161        global _require_active_variants_list
     162        foreach _require_active_variant $_require_active_variants_list {
     163                set name [lindex $_require_active_variant 0]
     164                set required [lindex $_require_active_variant 1]
     165                set forbidden [lindex $_require_active_variant 2]
    142166                if {[catch {set result [active_variants $name $required $forbidden]}] != 0} {
    143167                        error "$name is required, but not active."
     
    161185}
    162186
    163 proc _variant_in_variant_list {needle haystack} {
    164         foreach variant $haystack {
    165                 if {$variant == $needle} {
    166                         return 1
    167                 }
    168         }
    169         return 0
     187# register pre-configure handler that checks for all requested variants
     188pre-configure {
     189        _check_require_active_variants
    170190}
Note: See TracChangeset for help on using the changeset viewer.