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

Brad Phelan bradphelan at xtargets.com
Wed Jan 16 14:53:44 EST 2008

Andrew Chen wrote:
> Sorry, this email was never sent out due to mailing list problems.
> Here it is again...
> ----
> Brad,
> 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.
The language parser or Scanner as the SCons folks prefer to call is a 
modular as you wish it to be. It's only unseperated in that both 
everything is written in Python. I've written a few Scanners for SCons 
for custom builders and at least one for Rake. I ported the Rant C 
scanner to Rake. It may give you some inspiration for a Fortran one if 
you use Rake.


It seems that Fortran 95 support was added to SCons in 2004 if you want 
to take another peek.


> Also, I figured out a way to compile generated code already (see
> http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile?view=markup)
> At the start of rake file, I included one call:
> FruitProcessor.new.pre_process
> 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?
> Thanks
> ~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
> _______________________________________________
> Rake-devel mailing list
> Rake-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rake-devel

More information about the Rake-devel mailing list