Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Cc: mgorny@g.o
Subject: Re: [gentoo-dev] [PATCH 2/2] Use new multilib flags in autotools-multilib.
Date: Sat, 26 Jan 2013 15:29:12
Message-Id: 20130126122901.2e9c6aca@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH 2/2] Use new multilib flags in autotools-multilib. by "Michał Górny"
1 On Sat, 26 Jan 2013 16:06:35 +0100
2 Michał Górny <mgorny@g.o> wrote:
3
4 > On Sat, 26 Jan 2013 11:51:22 -0300
5 > Alexis Ballier <aballier@g.o> wrote:
6 >
7 > > On Sat, 26 Jan 2013 13:11:41 +0100
8 > > Michał Górny <mgorny@g.o> wrote:
9 > >
10 > > > On Wed, 23 Jan 2013 21:40:13 -0300
11 > > > Alexis Ballier <aballier@g.o> wrote:
12 > > >
13 > > > > On Thu, 24 Jan 2013 00:23:57 +0100
14 > > > > Michał Górny <mgorny@g.o> wrote:
15 > > > >
16 > > > > > This is mostly a proof-of-concept. If approved, I will work on
17 > > > > > moving the code into a separate eclass, possibly named
18 > > > > > 'multilib-build' ;). ---
19 > > > > > gx86/eclass/autotools-multilib.eclass | 24
20 > > > > > +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3
21 > > > > > deletions(-)
22 > > > > >
23 > > > > > diff --git a/gx86/eclass/autotools-multilib.eclass
24 > > > > > b/gx86/eclass/autotools-multilib.eclass index 7c8697a..eef7bcc
25 > > > > > 100644 --- a/gx86/eclass/autotools-multilib.eclass
26 > > > > > +++ b/gx86/eclass/autotools-multilib.eclass
27 > > > > > @@ -32,7 +32,23 @@ inherit autotools-utils multilib
28 > > > > >
29 > > > > > EXPORT_FUNCTIONS src_configure src_compile src_test
30 > > > > > src_install
31 > > > > > -IUSE=multilib
32 > > > > > +# Declare all of them, profiles will control their
33 > > > > > visibility. +IUSE='abi_x86_32 abi_x86_64'
34 > > > > > +
35 > > > > > +# @FUNCTION: _autotools-multilib_get_enabled_abis
36 > > > > > +# @DESCRIPTION:
37 > > > > > +# Get the list of enabled ABIs. The returned names are
38 > > > > > suitable for use +# with multilib.eclass.
39 > > > > > +#
40 > > > > > +# If multilib is not enabled or not supported, returns an
41 > > > > > empty list. +
42 > > > > > + debug-print-function ${FUNCNAME} "${@}"
43 > > > > > +
44 > > > > > + if use amd64; then
45 > > > > > + use abi_x86_64 && echo amd64
46 > > > > > + use abi_x86_32 && echo x86
47 > > > > > + fi
48 > > > > > +}
49 > > > >
50 > > > > I would rather iterate over a variable than hardcoding and
51 > > > > duplicating it here:
52 > > > >
53 > > > > MULTILIB_ABIS='abi_x86_32:x86 abi_x86_64:amd64'
54 > > > > IUSE=""
55 > > > > for i in $MULTILIB_ABIS ; do
56 > > > > IUSE+=" ${i%:*}"
57 > > > > done
58 > > > >
59 > > > > _autotools-multilib_get_enabled_abis() {
60 > > > > for i in $MULTILIB_ABIS ; do
61 > > > > use ${i%:*} && echo ${i#*:}
62 > > > > done
63 > > > > }
64 > > >
65 > > > What are the advantages? I feel like the explicit solution is much
66 > > > more readable and obvious at the first glance.
67 > >
68 > > yes it is more readable but IMHO it's better to avoid to have to
69 > > touch multiple places when adding a new ABI: you only have to
70 > > document that adding a new ABI consists simply in adding it to this
71 > > list (and document the useflag) instead of 'add the useflag, add
72 > > support for it to function foo and bar, etc.'
73 > > your call in the end, but I fear not trying to separate code from
74 > > data could make the eclass harder to maintain.
75 >
76 > Ok, separating data from code seems a valid concern. However, I feel
77 > like this is not really clear concept in bash, and the intent is that
78 > the ABI list will be used only in that function.
79
80 makes sense; the foo:bar trick is what I've came up in trying to emulate
81 python dictionaries :)
82
83
84 > > also, IMHO you shouldn't use arch to guess what useflag to check or
85 > > not: they'll all be in IUSE in the end and the profiles should be
86 > > the one deciding what to mask or not (which you'll have to do
87 > > anyway), not the eclass.
88 >
89 > Well, I think I've stated that already. That 'use foo &&' is just
90 > an optimization hack -- to not check all the irrelevant flags all
91 > the time.
92
93 I'm not sure 'optimizations' are relevant when we're going to build
94 twice the package here :P
95 Also, # of arches is about the same order of magnitude than # of abis,
96 thus checking # of arches time use $arch or # of abis times use $abi is,
97 in the end, comparable while checking arch adds the constraint that
98 the eclass and the profiles have to be in sync.
99
100 Alexis.