Skip to content

Commit

Permalink
Added variants.default to specify default variants. These do not over…
Browse files Browse the repository at this point in the history
…ride any

variants set by the client (command line).
Syntax:
variants.default +x11

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@1017 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
Kevin Van Vechten committed Oct 9, 2002
1 parent b450fa4 commit 4277771
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/port1.0/portutil.tcl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
package provide portutil 1.0 package provide portutil 1.0
package require Pextlib 1.0 package require Pextlib 1.0


global targets target_uniqid variants global targets target_uniqid all_variants


set targets [list] set targets [list]
set target_uniqid 0 set target_uniqid 0


set variants [list] set all_variants [list]


########### External High Level Procedures ########### ########### External High Level Procedures ###########


Expand Down Expand Up @@ -206,7 +206,7 @@ proc default_check {optionName index op} {
# variant <provides> [<provides> ...] [requires <requires> [<requires>]] # variant <provides> [<provides> ...] [requires <requires> [<requires>]]
# Portfile level procedure to provide support for declaring variants # Portfile level procedure to provide support for declaring variants
proc variant {args} { proc variant {args} {
global variants PortInfo global all_variants PortInfo
upvar $args upargs upvar $args upargs


set len [llength $args] set len [llength $args]
Expand Down Expand Up @@ -235,7 +235,7 @@ proc variant {args} {
$obj append provides $provides $obj append provides $provides
$obj append requires $requires $obj append requires $requires
$obj set code $code $obj set code $code
lappend variants $obj lappend all_variants $obj


# Export provided variant to PortInfo # Export provided variant to PortInfo
lappend PortInfo(variants) $provides lappend PortInfo(variants) $provides
Expand Down Expand Up @@ -379,7 +379,7 @@ proc include {fname} {
# all the globals in its scope. This is undeniably ugly, but I haven't # all the globals in its scope. This is undeniably ugly, but I haven't
# thought of any other way to do this. # thought of any other way to do this.
proc makeuserproc {name body} { proc makeuserproc {name body} {
regsub -- "^\{(.*)" $body "\{ \n foreach g \[info globals\] \{ \n global \$g \n \} \n \\1 " body regsub -- "^\{(.*?)" $body "\{ \n eval \"global \[info globals\]\" \n \\1" body
eval "proc $name {} $body" eval "proc $name {} $body"
} }


Expand Down Expand Up @@ -742,17 +742,17 @@ proc choose_variants {dlist variations} {
proc variant_run {this} { proc variant_run {this} {
set name [$this get name] set name [$this get name]
ui_debug "Executing $name provides [$this get provides]" ui_debug "Executing $name provides [$this get provides]"
makeuserproc $name-code "\{[$this get code]\}" makeuserproc ${name}-code "[$this get code]"
if ([catch $name-code result]) { if ([catch ${name}-code result]) {
ui_error "Error executing $name: $result" ui_error "Error executing $name: $result"
return 1 return 1
} }
return 0 return 0
} }


proc eval_variants {variations} { proc eval_variants {variations} {
global variants global all_variants
set dlist $variants set dlist $all_variants
upvar $variations upvariations upvar $variations upvariations
set chosen [choose_variants $dlist upvariations] set chosen [choose_variants $dlist upvariations]


Expand Down Expand Up @@ -994,7 +994,25 @@ proc variant_new {name} {
return $obj return $obj
} }



options variants.default
option_proc variants.default handle_variants.default
proc handle_variants.default {option action args} {
global variations
switch -regex $action {
set|append {
foreach v $args {
if {[regexp {([-+])([-A-Za-z0-9_]+)} $v whole val variant]} {
if {![info exists variations($variant)]} {
set variations($variant) $val
}
}
}
}
delete {
# xxx
}
}
}


##### portfile depspec subclass ##### ##### portfile depspec subclass #####
global portfile_vtbl global portfile_vtbl
Expand Down

0 comments on commit 4277771

Please sign in to comment.