[Rake-devel] Rule with multiple rule-based prereqs executes only first prereq

Robin Luckey robin at ohloh.net
Thu Oct 4 15:51:02 EDT 2007


If a rule-generated task has multiple prerequisites, only the first  
prerequisite may refer to a rule-generated task, otherwise the  
prerequisite task is not executed. The rakefile below demonstrates  
the bug:

Rakefile:
namespace :example do
   rule(/\ba$/)
   rule(/\bb$/)
   rule(/\bc$/ => ['a','b'])
end

Try it out:
$ rake example:c --dry-run
(in /Users/robin/projects/ohloh)
** Invoke example:c (first_time)
** Invoke a (first_time)
** Execute (dry run) a
** Execute (dry run) example:c

I expect that b would also execute. A correction patch follows.

Thanks,
Robin Luckey

Index: lib/rake.rb
===================================================================
--- lib/rake.rb (revision 609)
+++ lib/rake.rb (working copy)
@@ -1715,7 +1715,7 @@
        prereqs = sources.collect { |source|
          if File.exist?(source) || Rake::Task.task_defined?(source)
            source
-        elsif parent = enhance_with_matching_rule(sources.first,  
level+1)
+        elsif parent = enhance_with_matching_rule(source, level+1)
            parent.name
          else
            return nil



More information about the Rake-devel mailing list