Re: Attributes and :include
Tim Hemel <[email protected]> Mon, 27 Sep 2004 12:48:35 +0200
| Newsgroups | gmane.comp.tools.aap.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2004-09-27 at 12:22, Tim Hemel wrote:
> I am trying to debug an aap file and while doing that, I run into
> some strange behaviour, which is not the actual problem, but might
> be related.
>
> I have the following files:
>
> child.aap:
>
> @for i in var2list(Items):
> :print `get_attr(i)`
>
>
> ----------------------------------------------------
> parent.aap:
>
> Items = a { myattr=done }
> b { myattr=notdone }
> c
>
> :attr { all = mine } $Items
>
> @for i in var2list(_no.Items):
> :print `get_attr(i)` ...
>
> :include child.aap
> -----------------------------------------------------
>
>
> When I run this, I get the following output:
> [tim@localhost ~]$ aap -f parent.aap
> {'all': 'mine', 'myattr': 'done'} ...
> {'all': 'mine', 'myattr': 'notdone'} ...
> {'all': 'mine'} ...
> {'all': 'mine', 'myattr': 'done'}
> {'all': 'mine', 'myattr': 'notdone'}
> {'all': 'mine'}
> Aap: No target on the command line and no $TARGET, build rules or "all"
> target in a recipe
>
> Ok, so that works as expected, the attributes are available in both the
> parent and the child recipe.
>
> Now, I comment out the :attr command in the parent file, and we get an
> unexpected result:
> [tim@localhost ~]$ aap -f parent.aap
> {} ...
> {} ...
> {} ...
> {}
> {}
> {}
> Aap: No target on the command line and no $TARGET, build rules or "all"
> target in a recipe
>
> Hey! where did all my attributes go?
>
> The actual problem I am trying to solve has an :attr command, but tries
> to access the attributes from within a dependency and an action, where
> it, for some reason, fails to do this.
>
>
> Tim
>
Ok, I can reproduce the original bug as well. For this, I have changed
the child.aap to the following:
@for i in var2list(Items):
:mkdir {f} bla
:pushdir bla
:print `get_attr(i)`
:popdir
If I run the script now, I get:
[tim@localhost ~]$ aap -f parent.aap
{'all': 'mine', 'myattr': 'done'} ...
{'all': 'mine', 'myattr': 'notdone'} ...
{'all': 'mine'} ...
{}
{}
{}
Aap: No target on the command line and no $TARGET, build rules or "all"
target in a recipe
All attributes are gone, and it is apparently caused by the :pushdir
command. My workaround is to copy the variables first and then use them,
like:
@d = `get_attr(i)`
:pushdir bla
:print `d`
:popdir
Tim
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php