From: nobu@... Date: 2006-08-20T23:21:13+09:00 Subject: [rake] patch to rule Hi, The latest rake doesn't work with some patterns. 1) file name with source extension rule '.o' => %w[.c Rakefile] do |t| p "#{t.name} #{t.sources.join(' ')}" end 2) file name which starts with a dot file '.foo' rule '.o' => %w[.c .foo] do |t| p "#{t.name} #{t.sources.join(' ')}" end 3) target name without extension rule 'foo' => %w[.c] do |t| p "#{t.name} #{t.sources.join(' ')}" end It doesn't seem natural to replace the extension with the string which doesn't start with a dot. This is a patch to check it and allow file/task name starting with a dot. Index: lib/rake.rb =================================================================== --- lib/rake.rb (revision 568) +++ lib/rake.rb (working copy) @@ -1552,12 +1552,9 @@ # Attempt to create a rule given the list of prerequisites. def attempt_rule(task_name, extensions, block, level) - sources = make_sources(task_name, extensions) - prereqs = sources.collect { |source| + prereqs = make_sources(task_name, extensions) { |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 end } @@ -1573,7 +1570,8 @@ case ext when String - task_name.sub(/\.[^.]*$/, ext) + yield ext.sub(/\A(?=\.)/) {task_name.sub(/\.[^.]*$/, '')} or + yield ext or ext when Proc - ext.call(task_name) + yield ext.call(task_name) else fail "Don't know how to handle rule dependent: #{ext.inspect}" -- Nobu Nakada