[36956] branches/variant-descs-14482/base/src/port1.0/portutil.tcl
raimue at macports.org
raimue at macports.org
Tue May 20 20:02:24 PDT 2008
Revision: 36956
http://trac.macosforge.org/projects/macports/changeset/36956
Author: raimue at macports.org
Date: 2008-05-20 20:02:23 -0700 (Tue, 20 May 2008)
Log Message:
-----------
port1.0/portutil.tcl:
New proc variant_desc, reads global variant description file
Modified Paths:
--------------
branches/variant-descs-14482/base/src/port1.0/portutil.tcl
Modified: branches/variant-descs-14482/base/src/port1.0/portutil.tcl
===================================================================
--- branches/variant-descs-14482/base/src/port1.0/portutil.tcl 2008-05-21 03:01:11 UTC (rev 36955)
+++ branches/variant-descs-14482/base/src/port1.0/portutil.tcl 2008-05-21 03:02:23 UTC (rev 36956)
@@ -411,7 +411,7 @@
# variant <provides> [<provides> ...] [requires <requires> [<requires>]]
# Portfile level procedure to provide support for declaring variants
proc variant {args} {
- global all_variants PortInfo
+ global all_variants PortInfo porturl
set len [llength $args]
set code [lindex $args end]
@@ -449,6 +449,12 @@
} else {
lappend PortInfo(variants) $variant_provides
set vdesc [join [ditem_key $ditem description]]
+
+ # read global variant description, if none given
+ if {$vdesc == ""} {
+ set vdesc [variant_desc $porturl $variant_provides]
+ }
+
if {$vdesc != ""} {
lappend PortInfo(variant_desc) $variant_provides $vdesc
}
@@ -537,6 +543,47 @@
return 0
}
+##
+# Get description for a variant from global descriptions file
+#
+# @param porturl url to a port
+# @param variant name
+# @return description from descriptions file or an empty string
+proc variant_desc {porturl variant} {
+ global variant_descs_global
+
+ set sourceconfigdir [getsourceconfigdir $porturl]
+
+ if {$sourceconfigdir == ""} {
+ # protocol does not support global variants
+ return ""
+ }
+ set descfile [file join $sourceconfigdir variant_descriptions.conf]
+ if {![info exists variant_descs_global($sourceconfigdir)]} {
+ set variant_descs_global($sourceconfigdir) yes
+
+ if {[file exists $descfile]} {
+ set fd [open $descfile r]
+ set lineno 0
+ while {[gets $fd line] >= 0} {
+ incr lineno
+ if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
+ set variant_descs_global(${sourceconfigdir}_$option) $val
+ } else {
+ ui_warn "Invalid variant description in $descfile at line $lineno"
+ }
+ }
+ close $fd
+ }
+ }
+
+ if {[info exists variant_descs_global(${sourceconfigdir}_${variant})]} {
+ return $variant_descs_global(${sourceconfigdir}_${variant})
+ } else {
+ return ""
+ }
+}
+
# platform <os> [<release>] [<arch>]
# Portfile level procedure to provide support for declaring platform-specifics
# Basically, just wrap 'variant', so that Portfiles' platform declarations can
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080520/a5637e58/attachment.htm
More information about the macports-changes
mailing list