setting a variable in a variant for later use
Sean Farley
sean.michael.farley at gmail.com
Thu Oct 18 08:54:41 PDT 2012
On Thu, Oct 18, 2012 at 10:49 AM, Jonathan Stickel <jjstickel at gmail.com> 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?
I, too, wanted to avoid such code but didn't find a way around it.
Take a look at the boost portfile:
set pythons_suffixes {25 26 27 31 32 33}
set pythons_ports {}
foreach s ${pythons_suffixes} {
lappend pythons_ports python${s}
}
foreach s ${pythons_suffixes} {
set p python${s}
set v [string index ${s} 0].[string index ${s} 1]
set i [lsearch -exact ${pythons_ports} ${p}]
set c [lreplace ${pythons_ports} ${i} ${i}]
# python 3k conflicts with openmpi
(https://svn.boost.org/trac/boost/ticket/4657)
if { ${s} > 30 } { set o "openmpi" } else { set o "" }
eval [subst {
variant ${p} description "Build Boost.Python for Python ${v}"
conflicts ${c} ${o} debug {
# There is a conflict with python and debug support, so we
should really change the 'variant' line above
# to end with "conflicts ${c} debug" above. However, we
leave it enabled for those who want to try it.
# The issue has been reported to both the MacPorts team
and the boost team, as per:
# <http://trac.macports.org/ticket/23667> and
<https://svn.boost.org/trac/boost/ticket/4461>
depends_lib-append port:${p}
configure.args-delete --without-libraries=python
configure.args-append --with-python=${prefix}/bin/python${v}
patchfiles-append patch-tools-build-v2-tools-python.jam.diff \
patch-tools-build-v2-tools-python-2.jam.diff
post-patch {
reinplace s|@PREFIX@|${prefix}|
${worksrcpath}/tools/build/v2/tools/python.jam
}
}
}]
}
More information about the macports-dev
mailing list