Ignore:
Timestamp:
Dec 9, 2015, 9:54:37 PM (3 years ago)
Author:
pixilla@…
Message:

Improve perl variants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/_resources/port1.0/group/perl5-1.0.tcl

    r131727 r143285  
    7878# Set perl variant options and defaults
    7979options perl5.default_variant perl5.variant perl5.set_default_variant perl5.conflict_variants perl5.require_variant
     80# The default variant derived from perl5.default_branch if not set in Portfile.
    8081default perl5.default_variant {[string map {. _} perl${perl5.default_branch}]}
    81 default perl5.variant {[string map {. _} perl${perl5.major}]}
     82# The name of the selected variant or empty if there is not one.
     83default perl5.variant {}
     84# Control whether to set a default perl variant or not.
    8285default perl5.set_default_variant {true}
     86# Control whether to conflict the perl variants or not. Probably almost always true.
    8387default perl5.conflict_variants {true}
     88# Control whether a perl variant is required and if true produce an error if a perl variant is not set.
    8489default perl5.require_variant {false}
    8590# Get variant names from branches
     
    9398# Create perl variants
    9499proc perl5.create_variants {branches} {
    95     global name perl5.major perl5.default_variant perl5.variant perl5.set_default_variant perl5.conflict_variants perl5.require_variant
    96     set variants [perl5.get_variant_names ${branches}]
     100    global name perl5.major perl5.default_variant perl5.variant perl5.set_default_variant perl5.conflict_variants perl5.require_variant perl5.variants
     101    set perl5.variants [perl5.get_variant_names ${branches}]
    97102    foreach branch ${branches} {
    98103        set index [lsearch ${branches} ${branch}]
    99         set variant [lindex ${variants} ${index}]
     104        set variant [lindex ${perl5.variants} ${index}]
    100105# Add conflicts
    101106        set conflicts {}
    102107        if {${perl5.conflict_variants}} {
    103             set conflicts "conflicts {[lreplace ${variants} ${index} ${index}]}"
     108            set conflicts "conflicts {[lreplace ${perl5.variants} ${index} ${index}]}"
    104109        }
    105110        eval "variant ${variant} ${conflicts} description Use MacPorts perl${branch} {}"
     
    109114    }
    110115# Set default perl variant
    111     if {${perl5.default_variant} eq ${perl5.variant} && ${perl5.set_default_variant}} {
    112         default_variants-append +${perl5.variant}
    113     }
    114 # Require perl variant
    115     if {![variant_isset ${perl5.variant}] && ${perl5.require_variant}} {
    116         ui_error "${name} requires one of these variants: ${variants}"
    117         return -code error "absence of required perl variant"
     116    if {${perl5.variant} eq {} && ${perl5.set_default_variant}} {
     117        default_variants-append +${perl5.default_variant}
     118        if {[variant_isset ${perl5.default_variant}]} {
     119            perl5.variant ${perl5.default_variant}
     120        }
    118121    }
    119122# Set perl version and deps
    120123    foreach branch ${branches} {
    121124        set index [lsearch ${branches} ${branch}]
    122         set variant [lindex ${variants} ${index}]
     125        set variant [lindex ${perl5.variants} ${index}]
    123126        if {[variant_isset ${variant}]} {
    124127            perl5.major ${branch}
    125128            depends_lib-append port:perl${branch}
     129        }
     130    }
     131# Require perl variant
     132    pre-fetch {
     133        if {![variant_isset ${perl5.variant}] && ${perl5.require_variant}} {
     134            ui_error "${name} requires one of these variants: ${perl5.variants}"
     135            return -code error "absence of required perl variant"
    126136        }
    127137    }
Note: See TracChangeset for help on using the changeset viewer.