From: Mark Probert Date: 2005-04-01T08:34:36+09:00 Subject: Re: rake help Hi .. Many thanks, Jim. First, Rake is excellent! There is one part of the scenario that I'd like to explore, and a comment. On Thursday 31 March 2005 14:48, Jim Weirich wrote: > > rule '.cpp' => '.h' do |t| > sh "cxxtest.pl -o #{t.name} #{t.source}" > end I did get around to reading more of the documentation and have ended up using rules. My results where very similar to yours. When I created th.h -> .cpp rule, it would run against all .h files that it could find, rather than just the unit test ones. So I ended up with: UT_EXE = [ "test1", "test2", "test3" ] # all have a .h file defining tests rule '.cpp' => ['.h'] do |t| name = t.name.sub(/\.[^.]+$/, "") if UT_EXE.include?(name) sh( "#{CXXTEST} #{CXXTESTOPT} -o #{t.name} #{t.source}" ) end end I have also found that it is useful to have a dependency list for the various UTs, as not all of the UTs required all of the files of the application. So, something like the following works: UT_T1_DEP = [ "test1.cpp", "foo.o" ] UT_T2_DEP = [ "test2.cpp", "bar.o" ] UT_T3_DEP = [ "test3.cpp", "foo.o", "bar.o" ] My UT drivers look like: file "test1" => UT_T1_DEP do |t| sh( "#{CC} #{CCOPT} -o #{t.name} #{t.prerequisites.join(' ')}" ) end file "test2" => UT_T2_DEP do |t| sh( "#{CC} #{CCOPT} -o #{t.name} #{t.prerequisites.join(' ')}" ) end file "test3" => UT_T3_DEP do |t| sh( "#{CC} #{CCOPT} -o #{t.name} #{t.prerequisites.join(' ')}" ) end And the overall driver is a task: task :testsuite => UT_EXE do |t| puts "--> finished creating the tests" end The first question: is there a way to factor the UT drivers into a rule? I can't seem to get the dependcies right. Second: What is the best way of making this work in a sub-directory? Use explicit paths in the UT_*_DEP lines to ensure the link is right? Have a Rakefile in the UT director driven by one in the main directory? Again, many thanks for an excellent tool! I have been playing with Make and Jam for ages, and Rake has the potential to replace them all for me :-) Have you thought of doing the equivalent of Jambase and having a packaged library of default rules that will be applied, based on the platform that Rake is invoked on? So, if Linux, CC=gcc, if Win32 CC=cl, etc.. Regards, -- -mark. (probertm at acm dot org)