Re: Making targets that ignore :child

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Adriaan de Groot:

> [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

Although this mechanism is good, using the undocumented
"Global.cmd_args" is not a good idea.  Instead use the has_targetarg()
function.  An even more reliable method is also using
has_build_target():

	@if has_build_target() and not has_targetarg("cvs-update"):
		# :child commands


Hmm, only that this doesn't work when doing "aap cvs-update all",
because the presence of the "cvs-update" target will prefent the child
commands to be used, while they are needed for the "all" target.
But you probably won't do that anyway, since the "cvs-update" might
update the recipes.  Anyway, perhaps has_build_target() should accept a
list of targets that are not considered build targets, besides the
default ones.

-- 
Although the scythe isn't pre-eminent among the weapons of war, anyone who
has been on the wrong end of, say, a peasants' revolt will know that in
skilled hands it is fearsome.
					-- (Terry Pratchett, Mort)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
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.