I am using Rake for testing c++ code.

Incremental rebuild does not work for .h files,
Any ideas?


--
Simon Strandgaard






require 'rake/clean'

APPLICATION = 'test_code.exe'

CC = 'g++'
LD = CC

CFLAGS = [
  '-pedantic',
  '-fprofile-arcs -ftest-coverage',
  `cppunit-config --cflags`.strip
].join(' ')

LIBS = [
  `cppunit-config --libs`.strip
].join(' ')


CPP_SOURCES = FileList['test_code/*.cpp'] + FileList['code/*.cpp']

O_FILES = CPP_SOURCES.sub(/\.cpp$/, '.o')

file APPLICATION => O_FILES do |t|
  sh "#{LD} #{LIBS} #{O_FILES} -o #{t.name}"
end

rule ".o" => [".cpp"] do |t|
    sh "#{CC} #{CFLAGS} -c -o #{t.name} #{t.source}"
end


CLEAN.include("**/*.o")
CLEAN.include("**/*.bb")
CLEAN.include("**/*.bbg")
CLEAN.include("**/*.da")
CLOBBER.include(APPLICATION)
CLOBBER.include("**/*.gcov")


desc "compile the test executable."
task :compile => APPLICATION


desc "run all the tests."
task :test => APPLICATION do
  sh "./#{APPLICATION}"
end


rule ".gcov" => [".cpp"] do |t|
  path = t.source.sub(/\/[^\/]+\.cpp$/, '')
  sh "gcov -p --object-directory #{path} #{t.source}"
end


GCOV_FILES = CPP_SOURCES.sub(/\.cpp$/, '.gcov')

desc "output coverage info."
task :coverage => GCOV_FILES


task :default => :test