1 |
On Sat, Sep 6, 2008 at 9:00 PM, Alec Warner <antarus@g.o> wrote: |
2 |
> On Sat, Sep 6, 2008 at 10:36 AM, Thomas Anderson <gentoofan23@g.o> wrote: |
3 |
>> Hi, |
4 |
>> Currently we have a lot of: |
5 |
>> src_configure() { |
6 |
>> econf $(use_enable dvdr) \ |
7 |
>> $(use_with ipv6 ssl) \ |
8 |
>> --with-system-zlib |
9 |
>> } |
10 |
>> |
11 |
>> Introducing(Idea shamelessly taken from Exherbo): |
12 |
>> DEFAULT_SRC_CONFIGURE_USE_{WITHS,ENABLES} |
13 |
>> DEFAULT_SRc_CONFIGURE_EXTRA_PARAMS |
14 |
>> |
15 |
>> The code from above could be rewritten like so: |
16 |
>> |
17 |
>> DEFAULT_SRC_CONFIGURE_USE_ENABLES=( 'dvdr' ) |
18 |
>> DEFAULT_SRC_CONFIGURE_USE_WITHS=( 'ipv6 ssl' ) |
19 |
>> DEFAULT_SRC_CONFIGURE_EXTRA_PARAMS=( '--with-system-zlib' ) |
20 |
>> |
21 |
>> That's much simpler. |
22 |
> |
23 |
> It saves you 1 line and reduces readability and intuitiveness by a |
24 |
> fair margin; how is it simpler? |
25 |
> |
26 |
|
27 |
In the given example it's not a big deal. However, when you're dealing |
28 |
with more arguments it simplifies things. |
29 |
|
30 |
For example, this (based on an existing ebuild, but simplified a bit |
31 |
for brevity): |
32 |
|
33 |
-------------------------- |
34 |
src_compile() { |
35 |
local myconf=" |
36 |
--sysconfdir=/etc/${PN} |
37 |
--without-xgrid |
38 |
--enable-pretty-print-stacktrace |
39 |
--enable-orterun-prefix-by-default |
40 |
--without-slurm" |
41 |
|
42 |
if use threads; then |
43 |
myconf="${myconf} |
44 |
--enable-mpi-threads |
45 |
--with-progress-threads |
46 |
fi |
47 |
|
48 |
econf ${myconf} \ |
49 |
$(use_enable !nocxx mpi-cxx) \ |
50 |
$(use_enable romio io-romio) \ |
51 |
$(use_enable heterogeneous) \ |
52 |
$(use_with pbs tm) \ |
53 |
$(use_enable ipv6) \ |
54 |
|| die "econf failed" |
55 |
|
56 |
emake || die "emake failed" |
57 |
} |
58 |
-------------------------- |
59 |
|
60 |
becomes |
61 |
|
62 |
-------------------------- |
63 |
SRC_DEFAULT_CONFIGURE_WITHS=( "pbs tm" "ipv6" "threads progress-threads" |
64 |
SRC_DEFAULT_CONFIGURE_ENABLES=( |
65 |
"cxx mpi-cxx" |
66 |
"romio io-romio" |
67 |
"heterogeneous" |
68 |
"threads mpi-threads" |
69 |
SRC_DEFAULT_CONFIGURE_EXTRA_PARAMS=( |
70 |
--sysconfdir=/etc/${PN} |
71 |
--without-xgrid |
72 |
--enable-pretty-print-stacktrace |
73 |
--enable-orterun-prefix-by-default |
74 |
--without-slurm ) |
75 |
-------------------------- |
76 |
|
77 |
You save some lines, but also you keep out all the use_* calls with |
78 |
their backslashes, myconf=$myconf crap, econf/emake || die... |
79 |
|
80 |
Regards, |
81 |
-- |
82 |
Santiago M. Mola |
83 |
Jabber ID: cooldwind@×××××.com |