Re: Scopes for rules

Bram Moolenaar <[email protected]> Mon, 05 Jan 2004 21:45:16 +0100
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Richard Boulton wrote:

> Bram Moolenaar wrote:
> > The problem is not in Aap but in your recipe.
> > 
> > In your child recipe you only specify how to build "foo" from "foo.o".
> > There is no rule to build "foo.o" from "foo.c".  When Aap figures out
> > what to do, it sees that "foo.o" needs to be build and applies a default
> > rule to compile it from "foo.c".  But this rule works at the toplevel,
> > not in the child recipe.
> 
> Thanks - your reply helps, and I've got things working. :)
> 
> However - is there a reason why the rule has to work at the toplevel? 
> Would it be possible to define default rules for which variables are 
> evaluated at the level from which the rule was triggered, rather than 
> that in which the rule was defined?
> 
> I imagine this would require redefining the order in which scopes are 
> searched, and there may be consequences of this that I can't immediately 
> see. However, I found the behaviour rather surprising, and am just 
> wondering if there's a way to make it less surprising.

The problem is that it is difficult to decide what the origin of an
object file is.  It could be referred to in several (child) recipes.

In your example you might argue that the dependency where the object
file appears as a source defines the context for building this object
file.  But the same object file may be used as a source in several
dependencies, in several recipes.  Then what would the context be?

To keep things simple all rules are applied at the toplevel.  The rule
that applies then implies what scope is used.  Since the rule that you
use is a default one, this uses the scope of the toplevel.

If you want to specify a context for a certain object file, you can add
an attribute to it.  Oh, I suppose that's the third solution to your
original question:

	:attr $foo_objects {var_INCLUDE = $INCLUDE}

I can't think of a simple rule that would make this object file use the
context of the child recipe.  It would be something like "if a source
item is only mentioned in one recipe, use the scope of that recipe
first".  That doesn't sound very reliable to me.

> PS: any progress with my patch for the mingw tool?

Sorry, I have been busy with other things..

-- 
hundred-and-one symptoms of being an internet addict:
135. You cut classes or miss work so you can stay home and browse the web.

 /// 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 is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click