rake and implicit dependencies

B

Brad Phelan

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top