i have a Rakefile with a rule like this :
rule '.so' => '.cc' do |t|
puts "@ Compiling #{t.source}"
output = t.source.ext("so")
output['stdlib'] = 'build'
sh "mkdir -p #{File.dirname(output)}"
sh "#{CXX} #{t.source} -o#{output} #{STDLIB_CFLAGS} #{STDLIB_LFLAGS}"
end
As you can see, it generates many .so libraries from the ‘stdlib’ directory (which contains the sources) to the ‘build’ directory where the binaries are stored.
Now the problem is, due to this “directory exchange”, rake seems to not recognize the .so files as files it has generated, causing the recompilation of each .so module each time o run the rake command, even if nothing is changed.
Is there any way to solve this?
Thanks
You can either use the pathmap syntax or an explicit proc to change the output filename/path into the input filename/path.
The pathmap syntax will look something like this (untested):
The proc method will look something like this (also untested):
Note that you can get rid of the explicit ‘mkdir’ in your action and use a ‘directory’ task instead (if you know in advance the possible destination directories)