Gentoo Archives: gentoo-dev

From: Brian Harring <ferringb@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] new `usex` helper
Date: Wed, 14 Sep 2011 03:57:46
Message-Id: 20110914035657.GC5106@localhost.hobnob.com
In Reply to: Re: [gentoo-dev] new `usex` helper by Mike Frysinger
1 On Tue, Sep 13, 2011 at 11:43:48PM -0400, Mike Frysinger wrote:
2 > On Tuesday, September 13, 2011 23:04:06 Brian Harring wrote:
3 > > On Tue, Sep 13, 2011 at 10:45:27PM -0400, Mike Frysinger wrote:
4 > > > On Tuesday, September 13, 2011 19:08:09 Brian Harring wrote:
5 > > > > While a bit longer, we likely can gut most of the use_* logic to
6 > > > > use that, and it makes it easier to deal w/ the situations where a
7 > > > > configure's options always assume --enable-blah thus don't export the
8 > > > > option, but *do* export a --disable-blah.
9 > > >
10 > > > yeah, i thought about replacing use_{with,enable} with usex, but we'd
11 > > > have to extend usex() a little bit more
12 > >
13 > > Only extension I can think of is adding a prefix/postfix... which
14 > > frankly seems a bit too much. Anything else you were looking for?
15 >
16 > i dont think the postfix is needed for use_{enable,with}:
17 > usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; }
18 > use_enable() { usex $1 --enable-${2:-$1}${3:+=}$3 --disable-${2:-$1} ; }
19 > use_with() { usex $1 --with-${2:-$1}${3:+=}$3 --without-${2:-$1} ; }
20 >
21 > although adding it to usex is cheap, simplifies the other helpers a little,
22 > and might get used in more creative ways i cant imagine right now:
23 > usex() { use $1 && echo ${2:-yes}$4 || echo ${3:-no}$5 ; }
24 > use_enable() { usex $1 --{en,dis}able-${2:-$1} "${3:+=}$3" ; }
25 > use_with() { usex $1 --with{,out}-${2:-$1} "${3:+=}$3"; }
26 >
27 > so unless there's any other feedback, i'll open an EAPI bug on the topic and
28 > merge it to eutils.eclass
29
30 Might want to get EAPI sorted before it lands in eutils...
31
32 Either way, have at it, preferably less dense implementations however
33 ;)
34 ~harring