|
List Info
Thread: More general interface to use flags
|
|
| More general interface to use flags |
  Netherlands |
2007-11-02 08:43:05 |
|
| HI LIST,
THE CURRENT INTERFACE TO USE FLAGS, USEQ, USEV, USE_WITH, USE_ENABLE, AS
DEFINED IN /USR/LIB/PORTAGE/BIN/EBUILD.SH LACKS GENERALITY. THE COMMON THING
IS TESTING A USE FLAG AND POSSIBLY ECHOING A STRING, BUT THERE IS NO FUNCTION
THAT IMPLEMENTS THIS COMMON BEHAVIOUR.
I PROPOSE THAT WE ADD SUCH A FUNCTION. PROPOSED NAME FOR THE FUNCTION IS "IFUSE".
I ALSO PROPOSE TO ADD THE UTILITY FUNCTION "IFV" WHICH IS USEFUL FOR WRITING
CONCISE AND CLEAN CODE.
THESE ADDITIONS WOULD ALLOW YOU TO EASILY DEFINE YOUR OWN FUNCTION FOR
PROCESSING USE FLAGS IN EBUILDS AND ECLASSES. ONE SUCH EXAMPLE IS
USE_MIME() {
LOCAL WORD=$(IFV "$2" "$2" "$1")
IFUSE "$1" "$;"
}
FOR GENERATING A STRING OF ';'-SEPARATED MIME-TYPES BASED ON USE FLAGS.
THE EXPLANATION OF THIS FUNCTION IS:
#SET WORD TO ARGUMENT 2 OR IF THAT IS EMPTY TO ARGUMENT 1
#OUTPUT "$;" IF USE FLAG $1 IS SET (OR IF IT STARTS WITH ! AND IS UNSET)
#OTHERWISE DON'T OUTPUT ANYTHING
THE EXISTING INTERFACE IS ALSO SIMPLE TO REIMPLEMENT:
USE() {
IFUSE "$"
}
USEQ() {
IFUSE "$"
}
USEV() {
IFUSE "$" "$"
}
USE_WITH() {
LOCAL SUFFIX=$(IFV "$3" "=$3")
LOCAL WORD=$(IFV "$2" "$2" "$1")
IFUSE "$1" "--WITH-${WORD}${SUFFIX}" "--WITHOUT-$"
}
USE_ENABLE() {
LOCAL SUFFIX=$(IFV "$3" "=$3")
LOCAL WORD=$(IFV "$2" "$2" "$1")
IFUSE "$1" "--ENABLE-$${SUFFIX}" "--DISABLE-$"
}
IFUSE'S CODE IS MUCH LIKE USEQ'S CODE NOW, BUT MORE VERSATILE. YOU CAN FIND IT
ATTACHED ALONG WITH IFV.
PLEASE COMMENT,
MARIJN
--
MARIJN SCHOUTEN (HKBST), GENTOO LISP PROJECT
, #GENTOO-LISP ON FREENODE
|
| More general interface to use flags |
  Netherlands |
2007-11-02 09:52:36 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Drake wrote:
> Marijn Schouten (hkBst) wrote:
>> use_mime() {
>> local WORD=$(ifv "$2" "$2"
"$1")
>>
>> ifuse "$1" "$;"
>> }
>>
>> for generating a string of ';'-separated mime-types
based on use flags.
>>
>> The explanation of this function is:
>>
>> #set WORD to argument 2 or if that is empty to
argument 1
>> #output "$;" if use flag $1 is set
(or if it starts with ! and
>> is unset)
>> #otherwise don't output anything
>
> I don't quite understand what this function does. What
ebuild nastiness
> does it replace, or what does it allow that was not
previously possible?
> (can you give an example?)
It's something I built following some questions by lack in
#gentoo-dev-help.
Perhaps he can clarify if necessary.
[di okt 30 2007] [18:02:10]
<lack> Now, I want to have each ebuild have a
global variable called
'APPMIME' that somehow contains the mime-types available and
the associated
USE flags, such that the eclass that actually creates the
.desktop file can
appropriately go through and add only the mime-types that
are enabled by the
USE flags.
<zlin> no, there is no such convenience
function.
<lack> That's too bad - it would be pretty
useful. Oh well, I'll have to
write some sort of fancy function in the ebuild then.
<hkBst> lack: what about APPMIME="thing1
$(usev thing2)" ?
<zlin> I you think such a flattener would be
really useful I suppose you
can suggest it on -dev ..
<lack> hkBst: Hm, that's not too bad.
<zlin> *If
<lack> I wonder, would that work like:
APPMIME="one;$(if usev
thing2;thing3);thing4"?
<lack> Maybe I'd have to do some odd escaping in
that case of a
semicolon-separated list.
<hkBst> lack: why do you want it to be
;-separated?
<lack> Because that's the eventual format of
'MIME=type/one;type/two' in
the .desktop file.
<lack> If I could just set up the variable so the
eclass doesn't have to
actually do any parsing that would be easiest.
<lack> APPMIME="type/one;type/two$(if use
foo ';type/foo1;type/foo2')$(if
use bar ';type/barx;type/bary')" Perhaps?
<zlin> usemime() { useq $1 && echo
"$2;"; }; APPMIME="thing1;$(usemime
useflag thing2)$(usemime useflag2
"thing3;thing4")thing5"
<lack> Ah, that usemime feature looks useful,
thanks!
But
usemime() { useq $1 && echo "$2;"; }
lacks default arguments and ifuse provides a nicer interface
if you want to do
output, which is the use case I am proposing ifuse for.
Some other examples:
in dev-scheme/bigloo-3.0b_p2 I use (econf doesn't work):
./configure
$(use java && echo "--jvm=yes
--java=$(java-config --java)
- --javac=$(java-config --javac)")
- --prefix=/usr
# --bee=$(if use fullbee; then echo full; else echo partial;
fi)
it would be a bit nicer if I could just write:
./configure
$(ifuse java "--jvm=yes --java=$(java-config --java)
--javac=$(java-config
- --javac)")
- --prefix=/usr
# --bee=$(ifuse fullbee full partial)
The example from
<http://www.gentoo.org/proj/en/de
vrel/handbook/handbook.xml?part=2&chap=1>
if use gnutls ; then
myconf="$ --enable-ssl
--with-ssl=gnutls"
elif use ssl ; then
myconf="$ --enable-ssl
--with-ssl=openssl"
else
myconf="$ --disable-ssl"
fi
econf
# Other stuff
$
|| die "configure failed"
could become:
econf
# Other stuff
$(ifuse gnutls "--enable-ssl
--with-ssl=gnutls"
$(ifuse ssl "--enable-ssl --with-ssl=openssl"
--disable-ssl))
|| die "configure failed"
which may require some getting used to. But no functionality
will be lost, so
if you prefer the old way, all your existing methods will
continue to work.
There will just be another option.
Marijn
- --
Marijn Schouten (hkBst), Gentoo Lisp project
<http://www.ge
ntoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHKzmzp/VmCx0OL2wRAk8bAJ9rDW57WStJ79PBpXIbQN9phEv6GwCc
ChaR
OqLUSnsTRttVwFdmCwDnW7I=
=Zw+z
-----END PGP SIGNATURE-----
--
gentoo-portage-dev gentoo.org mailing list
|
|
| More general interface to use flags |
  Netherlands |
2007-11-02 09:53:53 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Drake wrote:
> Marijn Schouten (hkBst) wrote:
>> use_mime() {
>> local WORD=$(ifv "$2" "$2"
"$1")
>>
>> ifuse "$1" "$;"
>> }
>>
>> for generating a string of ';'-separated mime-types
based on use flags.
>>
>> The explanation of this function is:
>>
>> #set WORD to argument 2 or if that is empty to
argument 1
>> #output "$;" if use flag $1 is set
(or if it starts with ! and
>> is unset)
>> #otherwise don't output anything
>
> I don't quite understand what this function does. What
ebuild nastiness
> does it replace, or what does it allow that was not
previously possible?
> (can you give an example?)
It's something I built following some questions by lack in
#gentoo-dev-help.
Perhaps he can clarify if necessary.
[di okt 30 2007] [18:02:10]
<lack> Now, I want to have each ebuild have a
global variable called
'APPMIME' that somehow contains the mime-types available and
the associated
USE flags, such that the eclass that actually creates the
.desktop file can
appropriately go through and add only the mime-types that
are enabled by the
USE flags.
<zlin> no, there is no such convenience
function.
<lack> That's too bad - it would be pretty
useful. Oh well, I'll have to
write some sort of fancy function in the ebuild then.
<hkBst> lack: what about APPMIME="thing1
$(usev thing2)" ?
<zlin> I you think such a flattener would be
really useful I suppose you
can suggest it on -dev ..
<lack> hkBst: Hm, that's not too bad.
<zlin> *If
<lack> I wonder, would that work like:
APPMIME="one;$(if usev
thing2;thing3);thing4"?
<lack> Maybe I'd have to do some odd escaping in
that case of a
semicolon-separated list.
<hkBst> lack: why do you want it to be
;-separated?
<lack> Because that's the eventual format of
'MIME=type/one;type/two' in
the .desktop file.
<lack> If I could just set up the variable so the
eclass doesn't have to
actually do any parsing that would be easiest.
<lack> APPMIME="type/one;type/two$(if use
foo ';type/foo1;type/foo2')$(if
use bar ';type/barx;type/bary')" Perhaps?
<zlin> usemime() { useq $1 && echo
"$2;"; }; APPMIME="thing1;$(usemime
useflag thing2)$(usemime useflag2
"thing3;thing4")thing5"
<lack> Ah, that usemime feature looks useful,
thanks!
But
usemime() { useq $1 && echo "$2;"; }
lacks default arguments and ifuse provides a nicer interface
if you want to do
output, which is the use case I am proposing ifuse for.
Some other examples:
in dev-scheme/bigloo-3.0b_p2 I use (econf doesn't work):
./configure
$(use java && echo "--jvm=yes
--java=$(java-config --java)
- --javac=$(java-config --javac)")
- --prefix=/usr
# --bee=$(if use fullbee; then echo full; else echo partial;
fi)
it would be a bit nicer if I could just write:
./configure
$(ifuse java "--jvm=yes --java=$(java-config --java)
--javac=$(java-config
- --javac)")
- --prefix=/usr
# --bee=$(ifuse fullbee full partial)
The example from
<http://www.gentoo.org/proj/en/de
vrel/handbook/handbook.xml?part=2&chap=1>
if use gnutls ; then
myconf="$ --enable-ssl
--with-ssl=gnutls"
elif use ssl ; then
myconf="$ --enable-ssl
--with-ssl=openssl"
else
myconf="$ --disable-ssl"
fi
econf
# Other stuff
$
|| die "configure failed"
could become:
econf
# Other stuff
$(ifuse gnutls "--enable-ssl
--with-ssl=gnutls"
$(ifuse ssl "--enable-ssl --with-ssl=openssl"
--disable-ssl))
|| die "configure failed"
which may require some getting used to. But no functionality
will be lost, so
if you prefer the old way, all your existing methods will
continue to work.
There will just be another option.
Marijn
- --
Marijn Schouten (hkBst), Gentoo Lisp project
<http://www.ge
ntoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHKzmzp/VmCx0OL2wRAk8bAJ9rDW57WStJ79PBpXIbQN9phEv6GwCc
ChaR
OqLUSnsTRttVwFdmCwDnW7I=
=Zw+z
-----END PGP SIGNATURE-----
--
gentoo-portage-dev gentoo.org mailing list
|
|
[1-3]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|