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

Andrew Chen meihome at gmail.com
Wed Jan 16 13:42:55 EST 2008

Sorry, this email was never sent out due to mailing list problems.
Here it is again...



Thanks for your input.

SCons is a good tool.  I investigated in SCons 4 years ago.  What I
had problem with SCons was that it insisted on knowing too much about
the language to be built.  It builds internal dependencies.  At that
time, it does understand much of new FORTRAN 95 syntax, and we spent a
few days trying to write a F95 parser for SCons, and that turned me
off.  Maybe my knowledge is limited on new SCons features.

My build environment is mixed FORTRAN (F66, F90), C, Java.  I need
finer control of what the build tool would do.

What's good about Rake (and make included) is, it separate concerns
language parser and a build tool.

Also, I figured out a way to compile generated code already (see

At the start of rake file, I included one call:

So that the generated files are created before  SRC, and OBJ are built.

I switched totally from make to rake in the FORTRAN unit testing
framework.  It can handle multiple directories pretty well.  And the
amount of code I need to write for a new package is very minimal.

Rake experts - is this a "preferred/better" way to handle generated
source files to be compiled?

~Andrew Chen

On 09/01/2008, bradphelan <bradphelan at xtargets.com> wrote:
> 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.
> Regards
> Brad
> http://xtargets.com
> _______________________________________________
> Rake-devel mailing list
> Rake-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rake-devel

More information about the Rake-devel mailing list