Making targets that ignore :child

Adriaan de Groot <adridg-FlD2LfDziEhmR6Xm/[email protected]>
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
[Another "gosh, I just figured this out and felt like sharing" message.]

Sometimes, you don't need AAP to read all the child recipes in a given recipe. 
For example, you might have a target 'foo' defined in a recipe that you 
_know_ doesn't need anything from the children. More concretely, you might 
put this in a recipe where you're developing the sources yourself:

cvs-update {virtual} :
	:sys cvs update

(sure, you can probably use AAP's specific CVS support to better effect, but 
you get the idea). Now if you run "aap cvs-update", then surely there's no 
point in AAP reading in all the :child recipes that might occur here. 
Actually, if you're running this target, you don't need AAP to do anything 
else.

The list of targets given on the command line is stored in 
Global.cmd_args.targets. So you can inspect that in your recipe, and for 
instance only do :child commands if no target is specifically named on the 
command line. You could use this Python snippet:

@if not Global.cmd_args.targets:
    # :child commands go here

Of course, doing that makes many other targets - like "aap clean" and "aap 
install" useless as well, since for those targets you do want the children to 
be read. So a better approach is to check explicitly for the target(s) that 
obviate the need for children:

@if not "cvs-update" in Global.cmd_args.targets:
    # :child commands

-- 
pub  1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <[email protected]>
     Key fingerprint = 934E 31AA 80A7 723F 54F9  50ED 76AC EE01 FEA2 A3FE




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.