On 10/18/12 09:54 , Joshua Root wrote:
On 2012-10-19 02:49 , Jonathan Stickel wrote:
On 10/18/12 09:35 , Joshua Root wrote:
On 2012-10-19 02:16 , Jeremy Lavergne wrote:
I am trying to set a variable in a variant for later use in
another variant, but I am getting errors that the variable does
not exist. Here are the relevant lines:

Try wrapping your code in "if {[variant_isset ...]} {...}" rather
than inside a variant block--much like how default_variants is used
in your code.

That's probably the best approach, since variants aren't guaranteed
to be evaluated in any particular order.

- Josh


Thanks for the prompt, although terse, responses. I am not sure I
follow. It seems like this would create verbose, nested variants, which
I was hoping to avoid. Can you provide a simple example?

variant python26 conflicts python27 description {Configure to use Python
version 2.6} {}
variant python27 conflicts python26 description {Configure to use Python
version 2.7} {}

if { ![variant_isset python26] } {
     default_variants      +python27
}
if {[variant_isset python26]} {
     set python.version 26
} elseif {[variant_isset python27]} {
     set python.version 27
}

variant tkinter description {use py-tkinter backend} {
     depends_lib-append  port:py${python.version}-tkinter
}
variant pygtk description {use py-gtk backend} {
     depends_lib-append  port:py${python.version}-gtk
}

default_variants-append    +pygtk


Thanks! This is logical and works fine. I did not know empty variants were allowed.

I implemented the above and attached a patch to https://trac.macports.org/ticket/35791

Jonathan
_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macports-dev

Reply via email to