From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Inwtb-0005zt-VZ for garchives@archives.gentoo.org; Fri, 02 Nov 2007 13:49:12 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.1/8.14.0) with SMTP id lA2DlkCG021318; Fri, 2 Nov 2007 13:47:46 GMT Received: from pollux.sshunet.nl (pollux.sshunet.nl [145.97.192.42]) by robin.gentoo.org (8.14.1/8.14.0) with ESMTP id lA2DhdHw014801; Fri, 2 Nov 2007 13:43:39 GMT Received: from localhost (localhost.localdomain [127.0.0.1]) by pollux.sshunet.nl (Postfix) with ESMTP id 510E2580027; Fri, 2 Nov 2007 14:43:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at pollux.warande.net Received: from pollux.sshunet.nl ([127.0.0.1]) by localhost (pollux.sshunet.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AjZWTkcdN8wD; Fri, 2 Nov 2007 14:42:28 +0100 (CET) Received: from [145.97.223.26] (26pc223.sshunet.nl [145.97.223.26]) by pollux.sshunet.nl (Postfix) with ESMTP; Fri, 2 Nov 2007 14:42:28 +0100 (CET) Message-ID: <472B29B9.50002@gentoo.org> Date: Fri, 02 Nov 2007 14:44:25 +0100 From: "Marijn Schouten (hkBst)" User-Agent: Thunderbird 2.0.0.6 (X11/20070802) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 To: "gentoo-dev@lists.gentoo.org" CC: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-dev] More general interface to use flags X-Enigmail-Version: 0.95.4 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig88E6BA1683804162AAF3A267" X-Archives-Salt: f30633a4-facd-4535-b763-3cd5dc11cc1b X-Archives-Hash: 9fbff337428779865c2c50f6ea09a178 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig88E6BA1683804162AAF3A267 Content-Type: multipart/mixed; boundary="------------090109000902050109040200" This is a multi-part message in MIME format. --------------090109000902050109040200 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi list, the current interface to use flags, useq, usev, use_with, use_enable, as defined in /usr/lib/portage/bin/ebuild.sh lacks generality. The common th= ing is testing a use flag and possibly echoing a string, but there is no func= tion that implements this common behaviour. I propose that we add such a function. Proposed name for the function is = "ifuse". I also propose to add the utility function "ifv" which is useful for writ= ing concise and clean code. These additions would allow you to easily define your own function for processing use flags in ebuilds and eclasses. One such example is use_mime() { local WORD=3D$(ifv "$2" "$2" "$1") ifuse "$1" "${WORD};" } for generating a string of ';'-separated mime-types based on use flags. The explanation of this function is: #set WORD to argument 2 or if that is empty to argument 1 #output "${WORD};" if use flag $1 is set (or if it starts with ! and is u= nset) #otherwise don't output anything The existing interface is also simple to reimplement: use() { ifuse "${1}" } useq() { ifuse "${1}" } usev() { ifuse "${1}" "${1}" } use_with() { local SUFFIX=3D$(ifv "$3" "=3D$3") local WORD=3D$(ifv "$2" "$2" "$1") ifuse "$1" "--with-${WORD}${SUFFIX}" "--without-${WORD}" } use_enable() { local SUFFIX=3D$(ifv "$3" "=3D$3") local WORD=3D$(ifv "$2" "$2" "$1") ifuse "$1" "--enable-${WORD}${SUFFIX}" "--disable-${WORD}" } ifuse's code is much like useq's code now, but more versatile. You can fi= nd it attached along with ifv. Please comment, Marijn --=20 Marijn Schouten (hkBst), Gentoo Lisp project , #gentoo-lisp on FreeNode --------------090109000902050109040200 Content-Type: text/plain; name="new_use_interface" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="new_use_interface" IyB0ZXN0IGEgdXNlIGZsYWcgYW5kIHJldHVybiB0aGUgcmVzdWx0LCBwb3NzaWJseSBlY2hv IGEgbm9uLWVtcHR5IHN0cmluZwppZnVzZSgpIHsKICAgIGxvY2FsIGZsYWc9JDEKICAgIGxv Y2FsIHN0cmluZ19zdWNjZXNzPSQyCiAgICBsb2NhbCBzdHJpbmdfZmFpbHVyZT0kMwogICAg bG9jYWwgc3VjY2Vzcz0wCgogICAgIyBpbnZlcnQgdGhlIHJldHVybiB2YWx1ZSBmb3IgIiFi bGFoIiBhbmQgc3RyaXAgdGhlICchJwogICAgW1sgJHtmbGFnfSA9ICEqIF1dICYmIHsgc3Vj Y2Vzcz0xIDsgZmxhZz0ke2ZsYWc6MX0gfQoKICAgICMgTWFrZSBzdXJlIHdlIGhhdmUgdGhp cyBVU0UgZmxhZyBpbiBJVVNFCiAgICBpZiAhIGhhc3EgIiR7ZmxhZ30iICR7SVVTRX0gJHtF X0lVU0V9ICYmICEgaGFzcSAiJHtmbGFnfSIgJHtQT1JUQUdFX0FSQ0hMSVNUfSBzZWxpbnV4 OyB0aGVuCiAgICAgICAgZXFhd2FybiAiUUEgTm90aWNlOiBVU0UgRmxhZyAnJHtmbGFnfScg bm90IGluIElVU0UgZm9yICR7Q0FURUdPUll9LyR7UEZ9IgogICAgZmkKCiAgICBoYXNxICIk e2ZsYWd9IiAke1VTRX0gfHwgKChzdWNjZXNzPTEtc3VjY2VzcykpCgogICAgc3RyaW5nPSQo ICgoICR7c3VjY2Vzc30gPT0gMCApKSAmJiBlY2hvICR7c3RyaW5nX3N1Y2Nlc3N9IHx8IGVj aG8gJHtzdHJpbmdfZmFpbHVyZX0gKQogICAgW1sgLW4gJHtzdHJpbmd9IF1dICYmIGVjaG8g JHtzdHJpbmd9CiAgICByZXR1cm4gJHtzdWNjZXNzfQp9CgppZnYoKSB7CiAgICBbWyAtbiAk MSBdXSAmJiBlY2hvICQyIHx8IGVjaG8gJDMKfQo= --------------090109000902050109040200-- --------------enig88E6BA1683804162AAF3A267 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHKym5p/VmCx0OL2wRAhQaAKCB4VEt5SYdWPRgrQ5L10TzuZN5VACgqqde KC0ZqPz5KCU9BJH3cLfS0Co= =H8rP -----END PGP SIGNATURE----- --------------enig88E6BA1683804162AAF3A267-- -- gentoo-dev@gentoo.org mailing list