[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[rake] rule with regex executed twice for same matching string

Joel VanderWerf

11/7/2006 7:27:00 PM


Does anyone know why this rule is executed twice?

$ cat rakefile
task :default => "foo"

deps = [proc {"bar"}, proc {"barney"}]
rule /^foo$/ => deps

rule /^bar$/ do |t|
puts t.name
end

$ rake --trace
(in /home/vjoel/tmp/raketest)
** Invoke default (first_time)
** Invoke foo (first_time)
** Invoke bar (first_time)
** Execute bar
bar
bar
** Execute foo
*

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

1 Answer

Joel VanderWerf

11/10/2006 8:33:00 PM

0


This seems to be a bug in rake. It affects rules with multiple
prerequisites (but only if at least one prerequisite after the first is
a rule).

Here's a patch against the current rake gem version, 0.7.1:

$ diff -u rake.rb.bck rake.rb
--- rake.rb.bck 2006-11-10 12:11:32.000000000 -0800
+++ rake.rb 2006-11-10 12:11:32.000000000 -0800
@@ -1566,7 +1566,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


Joel VanderWerf wrote:
>
> Does anyone know why this rule is executed twice?
>
> $ cat rakefile
> task :default => "foo"
>
> deps = [proc {"bar"}, proc {"barney"}]
> rule /^foo$/ => deps
>
> rule /^bar$/ do |t|
> puts t.name
> end
>
> $ rake --trace
> (in /home/vjoel/tmp/raketest)
> ** Invoke default (first_time)
> ** Invoke foo (first_time)
> ** Invoke bar (first_time)
> ** Execute bar
> bar
> bar
> ** Execute foo
> *
>


--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407