Gentoo Archives: gentoo-portage-dev

From: "Marijn Schouten (hkBst)" <hkBst@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] use* cleanup
Date: Thu, 01 Nov 2007 15:38:46
Message-Id: 4729F341.9010300@gentoo.org
In Reply to: Re: [gentoo-portage-dev] use* cleanup by Mike Frysinger
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Mike Frysinger wrote:
5 > On Wednesday 31 October 2007, Marijn Schouten (hkBst) wrote:
6 >> I hope this is just an artifact of the patch being a bit opaque. The
7 >> inconsistent indentation in the patch is a consequence of emacs bash mode
8 >> using a different indentation style than (I guess) vi(m). I'm sure even in
9 >> vi you can re-indent my code with one simple key-chord.
10 >
11 > no idea, i dont use vi ... but you're writing the patch which means you get to
12 > fix it ;)
13
14 Sure, I can do that.
15
16 >> The immediate motivation of my examining this code was a request on
17 >> #gentoo-dev-help by lack for something which I could with my new code
18 >> easily write like this:
19 >>
20 >> use_mime() {
21 >> local WORD="$(_if $2 $2 $1)"
22 >>
23 >> _use $1 "${WORD};"
24 >> }
25 >
26 > write where ? in eclasses/ebuilds ?
27
28 yes
29
30 >> local SUFFIX="$(_if $3 "=$3")"
31 >> local WORD="$(_if $2 $2 $1)"
32 >
33 > local FOO=$(...)
34 > extraneous quoting makes eyes bleed
35 >
36 >> _if() {
37 >> if $1; then echo $2; else echo $3; fi
38 >> }
39 >
40 > $1 && echo $2 || echo $3
41
42 Sure :)
43
44 >> if hasq ${flag} ${USE} ; then
45 >> echo ${string_success}; return ${found}
46 >> else
47 >> echo ${string_failure}; return $((!found))
48 >> fi
49 >
50 > no point in cuddling those lines
51
52 Hmm, cuddling? I don't know what that means in this context.
53
54 >> What's not to like?
55 >
56 > when you've written it out, it does look much nicer ... but i'd like to
57 > understand the motivation behind it first ...
58
59 It seems the logical way to do it. Having a versatile function that checks use
60 flags and emits strings is very useful. Without it people will reimplement it
61 in a half-assed way time and time again in their ebuilds or eclasses. I've
62 done this myself. For example in dev-scheme/bigloo-3.0b_p2 I use:
63
64 ./configure \
65 $(use java && echo "--jvm=yes --java=$(java-config --java)
66 - --javac=$(java-config --javac)") \
67 - --prefix=/usr \
68 # --bee=$(if use fullbee; then echo full; else echo partial; fi)
69
70 it would be a bit nicer if I could just write:
71
72 ./configure \
73 $(_use java "--jvm=yes --java=$(java-config --java) --javac=$(java-config
74 - --javac)") \
75 - --prefix=/usr \
76 # --bee=$(_use fullbee full partial)
77
78 In gambit I used:
79
80 econf $(if use static; then echo --disable-shared; else echo --enable-shared;
81 fi) \
82
83 could become:
84
85 econf $(_use static --disable-shared --enable-shared) \
86
87 The example from
88 <http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=1>
89
90 if use gnutls ; then
91 myconf="${myconf} --enable-ssl --with-ssl=gnutls"
92 elif use ssl ; then
93 myconf="${myconf} --enable-ssl --with-ssl=openssl"
94 else
95 myconf="${myconf} --disable-ssl"
96 fi
97
98 econf \
99 # Other stuff
100 ${myconf} \
101 || die "configure failed"
102
103 could become:
104
105 econf \
106 # Other stuff
107 $(_use gnutls "--enable-ssl --with-ssl=gnutls" \
108 $(_use ssl "--enable-ssl --with-ssl=openssl" --disable-ssl)) \
109 || die "configure failed"
110
111 which may require some getting used to.
112
113 These are just a few small examples. I'm sure there are much better examples,
114 perhaps the use_mime thingy, but more importantly perhaps there is nothing
115 that you cannot do with the new code that you could do with the old.
116
117 Marijn
118
119 - --
120 Marijn Schouten (hkBst), Gentoo Lisp project
121 <http://www.gentoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode
122 -----BEGIN PGP SIGNATURE-----
123 Version: GnuPG v2.0.7 (GNU/Linux)
124 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
125
126 iD8DBQFHKfNBp/VmCx0OL2wRAuvfAJ9LUmLZ4SAMrGzgtF53MjDd+kLuVACeIRFY
127 eb+8W/SVH2R23y3RZ43b5Hk=
128 =fHxw
129 -----END PGP SIGNATURE-----
130 --
131 gentoo-portage-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-portage-dev] use* cleanup "Marijn Schouten (hkBst)" <hkBst@g.o>
Re: [gentoo-portage-dev] use* cleanup Mike Frysinger <vapier@g.o>