From: Simon Strandgaard Date: 2006-03-18T04:52:32+09:00 Subject: Re: incremental rebuild with Rake On 3/17/06, Simon Strandgaard wrote: > On 3/17/06, Simon Strandgaard wrote: > > I am using Rake for testing c++ code. > > > > Incremental rebuild does not work for .h files, > > Any ideas? > > I have made some changes to my .h files > and nothing happens when I type 'rake'! > > I wonder how to describe, that the application also > depends on the .h files. Anything smarter than converting makedepend to ruby, like this? -- Simon Strandgaard task :depend do sh "makedepend -f- -- #{CFLAGS} -- #{CPP_SOURCES} > .depend" end =begin input: code.o: code.h morecode.h output: {'code.o' => ['code.h', 'morecode.h']} =end def convert_makedepend_to_hash(filename) lines1 = IO.readlines(filename) # get rid of comments and empty lines lines2 = lines1.reject{|line| line =~ /^#|^\s*$/ } deps = {} lines2.each do |line| o_file, h_files_str = line.strip.split(': ') h_files = h_files_str.split(' ') deps[o_file] = h_files end deps end task :rakedepend do deps = convert_makedepend_to_hash('.depend') #p deps ary = [] deps.each do |o_file, deps| s = 'file "' + o_file + '" => ' + deps.inspect ary << s end result = ary.join("\n") result += "\n\n" File.open('.rakedepends', 'w+') {|f| f.write(result)} end load '.rakedepends'