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

Assaf Arkin assaf at labnotes.org
Wed Jan 16 17:18:10 EST 2008


On Jan 16, 2008 1:44 PM, Andrew Chen <hangfei at gmail.com> wrote:
> Assaf:
>
> > file('fruit_driver.f90'=>'fruit_basket.o')
> > file('fruit_basket.f90'=>'b.o')
> > file('b.f90'=>'a.o')
>
> 1. I don't want to maintain the list of all the *.f90 file in the
> build file.  I may have 20 of them.
> 2. The fruit_basket.f90 is generated code, it depending on all other
> *.f90 files in the directory.
>
> Is there a way I can add a rule like this?
> file('fruit_basket.f90'=>'*.o')

# Determine all the .o files from the .f90 files.
objs = FileList['*.f90'].map { |f| f.ext('o') }
# Depends on everything but itself.
file('fruit_basket.f90'=>objs - ['fruit_basket.o'])

Assaf

>
> or use ruby code to generate this file rule?
>
> Thanks
> ~Andrew Chen
>
>
> On 16/01/2008, Assaf Arkin <assaf at labnotes.org> wrote:
> > On Jan 16, 2008 10:49 AM, Andrew Chen <meihome at gmail.com> wrote:
> > > Rake experts,
> > >
> > > I still have problem to control the exact order of the compilation.
> > >
> > > I have a_test.f90, b_test.f90 file.  From those files, I have a
> > > pre-processor, that will generate:
> > > fruit_basket.f90, and fruit_driver.f90 files.
> > >
> > > The question is, I want make sure the order of compilation is:
> > > a.f90, b.f90, fruit_basket.f90, and fruit_driver.f90
> > >
> > > I used the file tasks:
> > >   rule '.o' => '.f90' do |t|
> > >     Rake::Task[:dirs].invoke
> > >     sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}
> > > #{lib_name_flag} #{lib_dir_flag}"
> > >   end
> >
> > You can add this:
> >
> > file('fruit_driver.f90'=>'fruit_basket.o')
> > file('fruit_basket.f90'=>'b.o')
> > file('b.f90'=>'a.o')
> >
> > Or do something like this:
> >
> > task 'compile'=>['a.o', 'b.o', 'fruit_basket.o', 'fruit_driver.o']
> >
> > -- Assaf
> > http://labnotes.org
> >
> > >
> > > Question:  how do I add the rules that will allow names with certain
> > > patterns compiled last?
> > >
> > > My working files are located here:
> > > http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile
> > > , and http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/rake_base.rb
> > >
> > > Thanks
> > > ~Andrew Chen
> > >
> > > _______________________________________________
> > > 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
> >
> _______________________________________________
> Rake-devel mailing list
> Rake-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rake-devel
>



-- 
-- Assaf

http://labnotes.org


More information about the Rake-devel mailing list