Gentoo Archives: gentoo-portage-dev

From: "Marijn Schouten (hkBst)" <hkBst@g.o>
To: gentoo-dev@l.g.o
Cc: gentoo-portage-dev@l.g.o, lack@g.o
Subject: [gentoo-portage-dev] Re: [gentoo-dev] More general interface to use flags
Date: Fri, 02 Nov 2007 14:53:44
Message-Id: 472B39B4.8040407@gentoo.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Daniel Drake wrote:
5 > Marijn Schouten (hkBst) wrote:
6 >> use_mime() {
7 >> local WORD=$(ifv "$2" "$2" "$1")
8 >>
9 >> ifuse "$1" "${WORD};"
10 >> }
11 >>
12 >> for generating a string of ';'-separated mime-types based on use flags.
13 >>
14 >> The explanation of this function is:
15 >>
16 >> #set WORD to argument 2 or if that is empty to argument 1
17 >> #output "${WORD};" if use flag $1 is set (or if it starts with ! and
18 >> is unset)
19 >> #otherwise don't output anything
20 >
21 > I don't quite understand what this function does. What ebuild nastiness
22 > does it replace, or what does it allow that was not previously possible?
23 > (can you give an example?)
24
25 It's something I built following some questions by lack in #gentoo-dev-help.
26 Perhaps he can clarify if necessary.
27
28 [di okt 30 2007] [18:02:10]
29 <lack> Now, I want to have each ebuild have a global variable called
30 'APPMIME' that somehow contains the mime-types available and the associated
31 USE flags, such that the eclass that actually creates the .desktop file can
32 appropriately go through and add only the mime-types that are enabled by the
33 USE flags.
34 <zlin> no, there is no such convenience function.
35 <lack> That's too bad - it would be pretty useful. Oh well, I'll have to
36 write some sort of fancy function in the ebuild then.
37 <hkBst> lack: what about APPMIME="thing1 $(usev thing2)" ?
38 <zlin> I you think such a flattener would be really useful I suppose you
39 can suggest it on -dev@ ..
40 <lack> hkBst: Hm, that's not too bad.
41 <zlin> *If
42 <lack> I wonder, would that work like: APPMIME="one;$(if usev
43 thing2;thing3);thing4"?
44 <lack> Maybe I'd have to do some odd escaping in that case of a
45 semicolon-separated list.
46 <hkBst> lack: why do you want it to be ;-separated?
47 <lack> Because that's the eventual format of 'MIME=type/one;type/two' in
48 the .desktop file.
49 <lack> If I could just set up the variable so the eclass doesn't have to
50 actually do any parsing that would be easiest.
51 <lack> APPMIME="type/one;type/two$(if use foo ';type/foo1;type/foo2')$(if
52 use bar ';type/barx;type/bary')" Perhaps?
53 <zlin> usemime() { useq $1 && echo "$2;"; }; APPMIME="thing1;$(usemime
54 useflag thing2)$(usemime useflag2 "thing3;thing4")thing5"
55 <lack> Ah, that usemime feature looks useful, thanks!
56
57 But
58
59 usemime() { useq $1 && echo "$2;"; }
60
61 lacks default arguments and ifuse provides a nicer interface if you want to do
62 output, which is the use case I am proposing ifuse for.
63
64 Some other examples:
65
66 in dev-scheme/bigloo-3.0b_p2 I use (econf doesn't work):
67
68 ./configure \
69 $(use java && echo "--jvm=yes --java=$(java-config --java)
70 - --javac=$(java-config --javac)") \
71 - --prefix=/usr \
72 # --bee=$(if use fullbee; then echo full; else echo partial; fi)
73
74 it would be a bit nicer if I could just write:
75
76 ./configure \
77 $(ifuse java "--jvm=yes --java=$(java-config --java) --javac=$(java-config
78 - --javac)") \
79 - --prefix=/usr \
80 # --bee=$(ifuse fullbee full partial)
81
82 The example from
83 <http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=1>
84
85 if use gnutls ; then
86 myconf="${myconf} --enable-ssl --with-ssl=gnutls"
87 elif use ssl ; then
88 myconf="${myconf} --enable-ssl --with-ssl=openssl"
89 else
90 myconf="${myconf} --disable-ssl"
91 fi
92
93 econf \
94 # Other stuff
95 ${myconf} \
96 || die "configure failed"
97
98 could become:
99
100 econf \
101 # Other stuff
102 $(ifuse gnutls "--enable-ssl --with-ssl=gnutls" \
103 $(ifuse ssl "--enable-ssl --with-ssl=openssl" --disable-ssl)) \
104 || die "configure failed"
105
106 which may require some getting used to. But no functionality will be lost, so
107 if you prefer the old way, all your existing methods will continue to work.
108 There will just be another option.
109
110 Marijn
111
112 - --
113 Marijn Schouten (hkBst), Gentoo Lisp project
114 <http://www.gentoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode
115 -----BEGIN PGP SIGNATURE-----
116 Version: GnuPG v2.0.7 (GNU/Linux)
117 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
118
119 iD8DBQFHKzmzp/VmCx0OL2wRAk8bAJ9rDW57WStJ79PBpXIbQN9phEv6GwCcChaR
120 OqLUSnsTRttVwFdmCwDnW7I=
121 =Zw+z
122 -----END PGP SIGNATURE-----
123 --
124 gentoo-portage-dev@g.o mailing list