Changes between Version 13 and Version 14 of PortfileRecipes


Ignore:
Timestamp:
Jan 1, 2010, 9:51:03 AM (14 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

total rewrite of variant_isset section

Legend:

Unmodified
Added
Removed
Modified
  • PortfileRecipes

    v13 v14  
    4949
    5050
    51 == variant_isset doesn't work when variant is set == #variant_isset
    52 Make sure you have the variant defined, even if it is empty, in the Portfile.  If all you need is to do something when the variant is set and not dedicate an entire variant section to it, variant_isset can work but you must still define the variant (or platform for things like darwin, darwin_9, etc).  So just add
    53 {{{
    54 variant myvariant {
    55 }
    56 }}}
    57 or
    58 {{{
    59 platform darwin 9 {
    60 }
    61 }}}
    62 Then port will set the variant when selected and variant_isset should work.
    63 
     51== variant_isset requires the variant to exist == #variant_isset
     52Normally you write the code for a variant inside the variant declaration:
     53
     54{{{
     55variant my_variant description {Variant description} {
     56    ...
     57    post-destroot {
     58        [post-destroot code for when the variant is set]
     59    }
     60}
     61}}}
     62
     63Sometimes it's more natural to include the variant's code in other sections of the Portfile by checking if the variant is (or is not) set:
     64
     65{{{
     66post-destroot {
     67    ...
     68    if {![variant_isset my_variant]} {
     69        [post-destroot code for when the variant is not set]
     70    }
     71}
     72}}}
     73
     74This is fine, but if you do it this way, you must ensure the variant is still defined in your Portfile, even if it is empty:
     75
     76{{{
     77variant my_variant description {Variant description} {}
     78}}}
    6479
    6580== Preferred use of default_variants == #default_variants