public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH multilib-build.eclass] Add multilib_native_use* functions to make ebuild writing easier.
@ 2014-04-19 10:53 Michał Górny
  2014-04-19 19:57 ` [gentoo-dev] " Jonathan Callen
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2014-04-19 10:53 UTC (permalink / raw
  To: gentoo-dev; +Cc: multilib, Michał Górny

People are either inlining this or creating local functions for this
purpose, so it'd be better to have them in the eclass.

RFC: what about '!use'? Should we invert the multilib_build_binaries
test as well?
---
 eclass/multilib-build.eclass | 48 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
index 77e7573..6adfc76 100644
--- a/eclass/multilib-build.eclass
+++ b/eclass/multilib-build.eclass
@@ -462,5 +462,53 @@ multilib_build_binaries() {
 	[[ ${COMPLETE_MULTILIB} == yes ]] || multilib_is_native_abi
 }
 
+# @FUNCTION: multilib_native_use_with
+# @USAGE: <flag> [<opt-name> [<opt-value>]]
+# @DESCRIPTION:
+# Output --with configure option alike use_with if USE <flag> is enabled
+# and executables are being built (multilib_build_binaries is true).
+# Otherwise, outputs --without configure option. Arguments are the same
+# as for use_with in the EAPI.
+multilib_native_use_with() {
+	if multilib_build_binaries; then
+		use_with "${@}"
+	else
+		echo "--without-${2:-${1}}"
+	fi
+}
+
+# @FUNCTION: multilib_native_use_enable
+# @USAGE: <flag> [<opt-name> [<opt-value>]]
+# @DESCRIPTION:
+# Output --enable configure option alike use_with if USE <flag>
+# is enabled and executables are being built (multilib_build_binaries
+# is true). Otherwise, outputs --disable configure option. Arguments are
+# the same as for use_enable in the EAPI.
+multilib_native_use_enable() {
+	if multilib_build_binaries; then
+		use_enable "${@}"
+	else
+		echo "--disable-${2:-${1}}"
+	fi
+}
+
+# @FUNCTION: multilib_native_usex
+# @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]]
+# @DESCRIPTION:
+# Output the concatenation of <true1> (or 'yes' if unspecified)
+# and <true2> if USE <flag> is enabled and executables are being built
+# (multilib_build_binaries is true). Otherwise, output the concatenation
+# of <false1> (or 'no' if unspecified) and <false2>. Arguments
+# are the same as for usex in the EAPI.
+#
+# Note: in EAPI 4 you need to inherit eutils to use this function.
+multilib_native_usex() {
+	if multilib_build_binaries; then
+		usex "${@}"
+	else
+		echo "${3-no}${5}"
+	fi
+}
+
 _MULTILIB_BUILD=1
 fi
-- 
1.9.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-19 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-19 10:53 [gentoo-dev] [PATCH multilib-build.eclass] Add multilib_native_use* functions to make ebuild writing easier Michał Górny
2014-04-19 19:57 ` [gentoo-dev] " Jonathan Callen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox