Reputation: 8553
I'm converting Makefile to Rakefile for small C++ project. I have src dir with *.h and *.cpp files and obj dir where all *.o goes (I don't want them in src). How to do it with Rake rules?
This works fine but I want to have a generic rule.
rule("#{OBJ_DIR}hello.o" => "#{SRC_DIR}hello.cpp") do |target|
This returns "Don't know how to handle rule dependent: /src\/(\w+).cpp/"
rule(/obj\/(\w+).o/ => /src\/(\w+).cpp/) do |target|
sh "#{COMPILER} #{FLAGS} -c -o #{target.name} #{target.source}"
end
Upvotes: 1
Views: 1384
Reputation: 9708
Copied shamelessly from here
rule '.o' => '.cpp' do |target|
sh "#{COMPILER} #{FLAGS} -c -o #{target.name} #{target.source}"
end
Maybe the problem lies in the fact that your example tries to mix where certain files are located, with the rule needed to handle any file with some extension regardless of it's location.
Upvotes: 2