[Rake-devel] rules with multiple prereqs

Jim Weirich jim at weirichhouse.org
Thu Jun 23 20:18:40 EDT 2005

On Thursday 23 June 2005 04:13 pm, Stuart Jansen wrote:
> Included is a patch that allows procs tied to rules to return multiple
> prerequisites.
> After considering multiple approaches, including writing writing a tool
> similar to makedepend for my project, I decided this was the cleanest
> approach. I have also included an example rakefile that uses this new
> feature.

Wow.  I'm still trying to wrap my head around the concept.  That's what I love 
about open source, you get contributions that you yourself would have never 
thought of.

Ok, lets see if I can explain your patch in words (just to make sure I 
understand your intention).  In your Rakefile, you wish to generate a .tex 
file from a .xml file.  The XML file includes other files.  If any of the 
include files (or the main .xml file) are more up to date than the .tex, 
the .tex file should be regenerated.

The only potential problem I see is a possibly interaction with the recursive 
rule logic.  If the main .xml file does't exist at the time the rule is 
evaluated (i.e. it too is generated by a rule), then the secondary prereqs 
will never be created.  This is probably ok because when this is the case, a 
file task  for the main .xml will be generated and (since it is a file task) 
the .xml will be generated, causing the .tex to be generated (because it is 
now out of date w.r.t. the .xml file.  In that case, the secondary prereqs 
don't matter ... But wait!  If the secondary prereqs are also not present 
(and generated by a rule), then they will never be generated because the 
main .xml didn't exist at the time prereqs were calculated. 

Sorry for the rambling of the previous paragraph.  I'm kinda thinking out 

It may be a case of caveat emptor, if you use rules in such ways, you really 
need to know what you are doing.

What I would like to see, is some test cases for the changes you sent.  
Particularly showing that the normal one source proc functionality isn't 
broken and that the enhancements work as advertised.  Some experimentation 
with the recursive rule/multiple source interaction might be worthwhile too.

Thanks for the patch.

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct, 
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rake-devel mailing list