Forum: Ruby rake and implicit dependencies

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brad P. (Guest)
on 2007-07-26 12:34
(Received via mailing list)
I am playing with Rake to build c projects and I run into this problem

#########
task :default => ['main.out']

file 'main.out'

rule '.out' => ['.o'] do |t|
   sh "cc #{t.source} -o #{t.name}"
end

rule '.o' => ['.c'] do |t|
   sh "cc #{t.source} -c -o #{t.name}"
end
#########

fails with the error

in /home/phelan/ruby/rake)
cc main.o -o main.out
cc: main.o: No such file or directory
cc: no input files
rake aborted!
Command failed with status (1): [cc main.o -o main.out...]
/home/phelan/ruby/rake/rakefile.rb:6
(See full trace by running task with --trace)

but the following works fine

task :default => ['main.out']

# file 'main.out'

rule '.out' => ['.o'] do |t|
   sh "cc #{t.source} -o #{t.name}"
end

rule '.o' => ['.c'] do |t|
   sh "cc #{t.source} -c -o #{t.name}"
end

Where is the subtlety that I am missing here?
This topic is locked and can not be replied to.