[Rake-devel] How to execute before the '.o' => '.f90' tasks?

bradphelan bradphelan at xtargets.com
Wed Jan 9 03:45:19 EST 2008

Andrew Chen wrote:
> Hi,
> First time to the list.  Thanks for your good work.
> I'm trying to use Rake to compile some FORTRAN and C codes.
> I have a task:
>   rule '.o' => '.f90' do |t|
>     sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}"
>   end
> But I have another task: generate_code, this task will make some more
> .f90 source files.
> I want to my generate code task to be executed before my rule '.o'
>    Rake::Task[:gen].invoke if Rake::Task.task_defined?('gen')
> How to do that?
I don't know but I played around with Rake for a while to build C/C++ 
and found it unsuitable. Whilst Rake is a great dependency tracking 
system for tasks it is not so great a tool for a general build system. I 
ended up turning to SCons which is a Python package though I prefer to 
do my general scripting in Ruby.

The things that SCons does better

- Construction environments
- Hierarchical project management
- Automatic clean rules
- The ability to glob the dependency tree as well as the file system 
which is great for
  when using code generators
- Many builders for C/C++/Fortran and others come by default with the 
SCons package. Most of the builders
  are automatically cross platform too. Windows/Linux builds are done 
with exactly the same commands.

That being said I think the Rake notation is nicer than SCons because 
Ruby is a nicer language. However Rake seems to be used primarily in 
Ruby based projects and there is not much development effort in making 
it friendly to other areas. This is not a criticism. Rake seems 
extremely good at what it does for the customers that use it. However 
for a general build engine I would recommend at least a look at SCons.




More information about the Rake-devel mailing list