Ignore:
Timestamp:
Oct 24, 2002, 10:35:05 AM (16 years ago)
Author:
kevin
Message:

Added path: class of depspec which is satisfied by a regex at an arbitrary
absolute or ${prefix}-relative path.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r1086 r1136  
    10701070
    10711071##### lib portfile depspec subclass #####
     1072# Search registry, then library path for regex
    10721073global libportfile_vtbl
    10731074array set libportfile_vtbl [array get portfile_vtbl]
     
    11261127
    11271128##### bin portfile depspec subclass #####
     1129# Search registry, then binary path for regex
    11281130global binportfile_vtbl
    11291131array set binportfile_vtbl [array get portfile_vtbl]
     
    11521154        set search_path [split $env(PATH) :]
    11531155       
     1156        set depregex \^$depregex\$
     1157       
     1158        return [portfile_search_path $depregex $search_path]
     1159    }
     1160}
     1161
     1162##### path portfile depspec subclass #####
     1163# Search registry, then search specified absolute or
     1164# ${prefix} relative path for regex
     1165global pathportfile_vtbl
     1166array set pathportfile_vtbl [array get portfile_vtbl]
     1167set pathportfile_vtbl(test) pathportfile_test
     1168
     1169proc pathportfile_new {name match} {
     1170    set obj [portfile_new $name]
     1171   
     1172    $obj set _vtbl pathportfile_vtbl
     1173    $obj set depregex $match
     1174    return $obj
     1175}
     1176
     1177proc pathportfile_test {this} {
     1178    global env prefix
     1179   
     1180    # Check the registry first
     1181    set result [portfile_test $this]
     1182    if {$result == 1} {
     1183        return $result
     1184    } else {
     1185        # Not in the registry, check the path.
     1186        # separate directory from regex
     1187        set fullname [$this get depregex]
     1188
     1189        regexp {^(.*)/(.*?)$} "$fullname" match search_path depregex
     1190
     1191        if {[string index $search_path 0] != "/"} {
     1192                # Prepend prefix if not an absolute path
     1193                set search_path "${prefix}/${search_path}"
     1194        }
     1195               
    11541196        set depregex \^$depregex\$
    11551197       
Note: See TracChangeset for help on using the changeset viewer.