Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: multilib@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH multilib-build.eclass] Add multilib_native_use* functions to make ebuild writing easier.
Date: Sat, 19 Apr 2014 10:53:38
Message-Id: 1397904806-3079-1-git-send-email-mgorny@gentoo.org
1 People are either inlining this or creating local functions for this
2 purpose, so it'd be better to have them in the eclass.
3
4 RFC: what about '!use'? Should we invert the multilib_build_binaries
5 test as well?
6 ---
7 eclass/multilib-build.eclass | 48 ++++++++++++++++++++++++++++++++++++++++++++
8 1 file changed, 48 insertions(+)
9
10 diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
11 index 77e7573..6adfc76 100644
12 --- a/eclass/multilib-build.eclass
13 +++ b/eclass/multilib-build.eclass
14 @@ -462,5 +462,53 @@ multilib_build_binaries() {
15 [[ ${COMPLETE_MULTILIB} == yes ]] || multilib_is_native_abi
16 }
17
18 +# @FUNCTION: multilib_native_use_with
19 +# @USAGE: <flag> [<opt-name> [<opt-value>]]
20 +# @DESCRIPTION:
21 +# Output --with configure option alike use_with if USE <flag> is enabled
22 +# and executables are being built (multilib_build_binaries is true).
23 +# Otherwise, outputs --without configure option. Arguments are the same
24 +# as for use_with in the EAPI.
25 +multilib_native_use_with() {
26 + if multilib_build_binaries; then
27 + use_with "${@}"
28 + else
29 + echo "--without-${2:-${1}}"
30 + fi
31 +}
32 +
33 +# @FUNCTION: multilib_native_use_enable
34 +# @USAGE: <flag> [<opt-name> [<opt-value>]]
35 +# @DESCRIPTION:
36 +# Output --enable configure option alike use_with if USE <flag>
37 +# is enabled and executables are being built (multilib_build_binaries
38 +# is true). Otherwise, outputs --disable configure option. Arguments are
39 +# the same as for use_enable in the EAPI.
40 +multilib_native_use_enable() {
41 + if multilib_build_binaries; then
42 + use_enable "${@}"
43 + else
44 + echo "--disable-${2:-${1}}"
45 + fi
46 +}
47 +
48 +# @FUNCTION: multilib_native_usex
49 +# @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]]
50 +# @DESCRIPTION:
51 +# Output the concatenation of <true1> (or 'yes' if unspecified)
52 +# and <true2> if USE <flag> is enabled and executables are being built
53 +# (multilib_build_binaries is true). Otherwise, output the concatenation
54 +# of <false1> (or 'no' if unspecified) and <false2>. Arguments
55 +# are the same as for usex in the EAPI.
56 +#
57 +# Note: in EAPI 4 you need to inherit eutils to use this function.
58 +multilib_native_usex() {
59 + if multilib_build_binaries; then
60 + usex "${@}"
61 + else
62 + echo "${3-no}${5}"
63 + fi
64 +}
65 +
66 _MULTILIB_BUILD=1
67 fi
68 --
69 1.9.2

Replies