From 07a0d2875d93c658d14a0ce87ce95b4150977596 Mon Sep 17 00:00:00 2001 From: Tim Yamin Date: Wed, 22 Feb 2006 04:01:23 +0000 Subject: More goodies; change syntax highlighting mode within quotes for ebuilds. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/devmanual/trunk@5 176d3534-300d-0410-8db8-84e73ed771c3 --- ebuild-writing/use-conditional-code/text.xml | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ebuild-writing/use-conditional-code/text.xml (limited to 'ebuild-writing/use-conditional-code') diff --git a/ebuild-writing/use-conditional-code/text.xml b/ebuild-writing/use-conditional-code/text.xml new file mode 100644 index 0000000..84fc490 --- /dev/null +++ b/ebuild-writing/use-conditional-code/text.xml @@ -0,0 +1,62 @@ + + + +USE Flag Conditional Code + + +

+Often a particular block of code must only be executed if a given USE flag is +set (or unset). For large blocks, if use foo is best, or for inverse tests +either if ! use foo or if use !foo can be used (the former is more +common and is recommended for readability). For single-statement conditions, the +use foo && blah (or use foo || blah for negatives) form is often more +readable. +

+ +

+The if [ "`use foo`" ] and if [ -n "`use foo`" ] forms which are +occasionally seen in older code must not be used. +

+ + +die will not work as expected within a subshell, so code in the +form use foo && ( blah ; blah ) should be avoided in favour of a proper if +statement. See `die and Subshells`_. + + + + # USE conditional blocks... + if use livecd ; then + # remove some extra files for a small livecd install + rm -fr ${vimfiles}/{compiler,doc,ftplugin,indent} + fi + + # Inverse USE conditional blocks... + if ! use cscope ; then + # the --disable-cscope configure arg doesn't quite work properly, + # so sed it out of feature.h if we're not USEing cscope. + sed -i -e '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope" + fi + + # USE conditional statements... + use ssl && epatch ${FILESDIR}/${P}-ssl.patch + use sparc && filter-flags -fomit-frame-pointer + + # Inverse USE conditional statements... + use ncurses || epatch ${FILESDIR}/${P}-no-ncurses.patch + + +

+For echoing content based upon a USE flag, there is often a better helper +function available. +

+ +

+You must not rely upon use producing an output -- this no longer happens. +If you really need output displayed, use the usev function. The +useq function is available for explicitly requesting no output. +

+ + +
+
-- cgit v1.2.3-65-gdbad