[MacPorts] PortfileRecipes modified

MacPorts noreply at macports.org
Fri Jan 1 01:51:18 PST 2010


Changed page "PortfileRecipes" by ryandesign at macports.org from 70.253.75.177*
Page URL: <http://trac.macports.org/wiki/PortfileRecipes>
Diff URL: <http://trac.macports.org/wiki/PortfileRecipes?action=diff&version=14>
Revision 14
Comment: total rewrite of variant_isset section

-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: PortfileRecipes
=========================================================================
--- PortfileRecipes (version: 13)
+++ PortfileRecipes (version: 14)
@@ -48,19 +48,34 @@
 }}}
 
 
-== variant_isset doesn't work when variant is set == #variant_isset
-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
-{{{
-variant myvariant {
-}
-}}}
-or
-{{{
-platform darwin 9 {
-}
-}}}
-Then port will set the variant when selected and variant_isset should work.
-
+== variant_isset requires the variant to exist == #variant_isset
+Normally you write the code for a variant inside the variant declaration:
+
+{{{
+variant my_variant description {Variant description} {
+    ...
+    post-destroot {
+        [post-destroot code for when the variant is set]
+    }
+}
+}}}
+
+Sometimes 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:
+
+{{{
+post-destroot {
+    ...
+    if {![variant_isset my_variant]} {
+        [post-destroot code for when the variant is not set]
+    }
+}
+}}}
+
+This 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:
+
+{{{
+variant my_variant description {Variant description} {}
+}}}
 
 == Preferred use of default_variants == #default_variants
 Currently negating a variant (through {{{-variant}}}) is not remembered which means a {{{port upgrade}}} will not keep that negation around.  This causes issues with default_variants which must be kept in mind (ticket #2377).

-------8<------8<------8<------8<------8<------8<------8<------8<--------

* The IP shown here might not mean anything if the user or the server is
behind a proxy.

--
MacPorts <http://www.macports.org/>
Ports system for Mac OS

This is an automated message. Someone at http://www.macports.org/ added your email
address to be notified of changes on PortfileRecipes. If it was not you, please
report to .


More information about the macports-changes mailing list