[Rake-devel] adding targets

Shea Martin shea08 at eastlink.ca
Wed Jan 10 15:52:26 EST 2007

I have a rakefile which takes a C++ source tree, and creates objects 

i.e., source/dir/file.cpp compiles to build/dir/file.o.  I created a 
rule for this, and all works well.

Often it is handy to compile a single file based on just the source 
path, without wanting to resolve what the object file will be.  (i.e, 
from Vim, calling 'rake expand("%")' ).

So I created a task like this:

task :singleobj do |t|
	src = ENV['srcfile']
	obj = src.pathmap( "%{^source,build}.o" )
	sh( "rake #{obj}" )

This allows me to issue the command from Vim
'rake singleobj srcfile=source/dir/file.cpp'

This is good, but the rake command is called twice.  Is there a way I 
can avoid calling rake recursively?



More information about the Rake-devel mailing list