Changeset 24678
- Timestamp:
- 04/29/07 15:50:55 (19 months ago)
- Location:
- trunk/base
- Files:
-
- 3 modified
-
ChangeLog (modified) (1 diff)
-
src/port1.0/portdepends.tcl (modified) (1 diff)
-
src/port1.0/portutil.tcl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/ChangeLog
r24549 r24678 6 6 7 7 (unreleased): 8 9 - variable tracing now works in a much better way and handles unsets properly. 10 Similarly, ${option}-delete now works better. Depends validation no longer 11 attempts to validate when the variable is unset. Additionally, the validation 12 now actually validates each depspec instead of simply finding a single spec 13 within the list that works (ticket #11868, eridius r24678). 8 14 9 15 - macports infrastructure now easier to use from scripts. -
trunk/base/src/port1.0/portdepends.tcl
r22003 r24678 43 43 option_proc depends_lib validate_depends_options 44 44 45 proc validate_depends_options {option action args} {45 proc validate_depends_options {option action {value ""}} { 46 46 global targets 47 switch -regex$action {48 set |append|delete{49 foreach depspec $ args{47 switch $action { 48 set { 49 foreach depspec $value { 50 50 switch -regex $depspec { 51 (lib|bin|path):([-A-Za-z0-9_/.${}^?+()|\\\\]+):([-A-Za-z./0-9_]+){}52 (port):([-A-Za-z./0-9_]+){}51 ^(lib|bin|path):([-A-Za-z0-9_/.${}^?+()|\\\\]+):([-A-Za-z./0-9_]+)$ {} 52 ^(port):([-A-Za-z./0-9_]+)$ {} 53 53 default { return -code error [format [msgcat::mc "invalid depspec: %s"] $depspec] } 54 54 } -
trunk/base/src/port1.0/portutil.tcl
r24608 r24678 91 91 proc options {args} { 92 92 foreach option $args { 93 proc $option {args} "94 global $ {option}user_options option_procs95 if {! \[info exists user_options(${option})\]} {96 set $ {option}\$args93 proc $option {args} [subst -nocommands { 94 global $option user_options option_procs 95 if {![info exists user_options($option)]} { 96 set $option \$args 97 97 } 98 " 99 proc ${option}-delete {args} " 100 global ${option} user_options option_procs 101 if {!\[info exists user_options(${option})\] && \[info exists ${option}\]} { 98 }] 99 proc ${option}-delete {args} [subst -nocommands { 100 global $option user_options option_procs 101 if {![info exists user_options($option)] && [info exists $option]} { 102 set temp $option 102 103 foreach val \$args { 103 set ${option} \[ldelete \${$option} \$val\]104 set temp [ldelete \${$option} \$val] 104 105 } 105 if {\[string length \${${option}}\] == 0} { 106 unset ${option} 106 if {\$temp eq ""} { 107 unset $option 108 } else { 109 set $option \$temp 107 110 } 108 111 } 109 "110 proc ${option}-append {args} "111 global $ {option}user_options option_procs112 if {! \[info exists user_options(${option})\]} {113 if { \[info exists ${option}\]} {114 set $ {option} \[concat \${$option} \$args\]112 }] 113 proc ${option}-append {args} [subst -nocommands { 114 global $option user_options option_procs 115 if {![info exists user_options($option)]} { 116 if {[info exists $option]} { 117 set $option [concat \${$option} \$args] 115 118 } else { 116 set $ {option}\$args119 set $option \$args 117 120 } 118 121 } 119 "122 }] 120 123 } 121 124 } … … 123 126 proc options_export {args} { 124 127 foreach option $args { 125 proc options::export-${option} {args} " 126 global ${option} PortInfo 127 if {\[info exists ${option}\]} { 128 set PortInfo(${option}) \${${option}} 129 } else { 130 unset PortInfo(${option}) 128 proc options::export-${option} {option action {value ""}} [subst -nocommands { 129 global $option PortInfo 130 switch \$action { 131 set { 132 set PortInfo($option) \$value 133 } 134 delete { 135 unset PortInfo($option) 136 } 131 137 } 132 "133 option_proc $ {option} options::export-${option}138 }] 139 option_proc $option options::export-$option 134 140 } 135 141 } … … 141 147 # Display a warning 142 148 if {$newoption != ""} { 143 proc warn_deprecated_${option} {option action args} "149 proc warn_deprecated_${option} {option action args} [subst -nocommands { 144 150 global portname $option $newoption 145 if {\$action != \"read\"} {151 if {\$action != "read"} { 146 152 $newoption \$$option 147 153 } else { 148 ui_warn \"Port \$portname using deprecated option \\\"$option\\\".\"154 ui_warn "Port \$portname using deprecated option \\\"$option\\\"." 149 155 $option \[set $newoption\] 150 156 } 151 "157 }] 152 158 } else { 153 proc warn_deprecated_$option {option action args} "159 proc warn_deprecated_$option {option action args} [subst -nocommands { 154 160 global portname $option $newoption 155 ui_warn \"Port \$portname using deprecated option \\\"$option\\\".\"156 "161 ui_warn "Port \$portname using deprecated option \\\"$option\\\"." 162 }] 157 163 } 158 164 option_proc $option warn_deprecated_$option … … 161 167 proc option_proc {option args} { 162 168 global option_procs $option 163 eval lappend option_procs($option) $args 164 # Add a read trace to the variable, as the option procedures have no access to reads 165 trace variable $option rwu option_proc_trace 169 if {[info exists option_procs($option)]} { 170 set option_procs($option) [concat $option_procs($option) $args] 171 # we're already tracing 172 } else { 173 set option_procs($option) $args 174 trace add variable $option {read write unset} option_proc_trace 175 } 166 176 } 167 177 … … 170 180 proc option_proc_trace {optionName index op} { 171 181 global option_procs 172 upvar $optionName optionValue182 upvar $optionName $optionName 173 183 switch $op { 174 w {184 write { 175 185 foreach p $option_procs($optionName) { 176 $p $optionName set $optionValue186 $p $optionName set [set $optionName] 177 187 } 178 return 179 } 180 r { 188 } 189 read { 181 190 foreach p $option_procs($optionName) { 182 191 $p $optionName read 183 192 } 184 return 185 } 186 u { 193 } 194 unset { 187 195 foreach p $option_procs($optionName) { 188 $p $optionName delete 189 trace vdelete $optionName rwu $p 196 if {[catch {$p $optionName delete} result]} { 197 ui_debug "error during unset trace ($p): $result\n$::errorInfo" 198 } 190 199 } 191 return200 trace add variable $optionName {read write unset} option_proc_trace 192 201 } 193 202 }

