From: Mark Probert Date: 2005-04-02T09:45:33+09:00 Subject: Re: rake help Hi .. On Friday 01 April 2005 05:18, Jim Weirich wrote: > > Likewise, a pattern based rule might work here too (again, untested): > > rule(/^test\d+$/, '.cpp') do |t| > sh "#{CC} #{CCOPT} -o #{t.name} #{t.prerequisites.join(' ')}" > end > Works well. My rule looks like: rule( '.exe' => [ proc {|tn| tn.sub(/\.[^.]+$/, '.cpp').insert(0, "#{UT_DIR}\/") } ]) do |t| bn = t.name.sub("\.exe", "") objlist = check_dep(UT_DIR + "/" + bn + ".h") sh( "#{CC} #{CCOPT} -o #{UT_DIR}/#{bn} #{t.prerequisites.join(' ')} \ #{objlist}" ) end So, I use a synthetic target and use the check_dep() call to extract the dependent .o file from the #include (thanks for the tip :-) ). > And then the dependencies can be given explicitly. > > file "test1" => ["test1.cpp", "foo.o"] > This also works, though I don't think that I have dependencies are quite right. In order to get things to work correctly, I have created a synthetic target that enables an extension rule to be triggered. So: file "ut_buffer" => [ "scanner.o", "ut_buffer.exe", ] do |t| puts " .. running tests --> #{t.name}" sh( "#{UT_DIR}/#{t.name}" ) end So, this works well, though I would like not to have to specify the ".o" dependency on the UT driver line. I assume that the way to do this is to add the check_dep() to the proc and join the list to the prerequisites? Regards, -- -mark. (probertm at acm dot org)