From: Jim Weirich Date: 2006-03-18T06:21:23+09:00 Subject: Re: incremental rebuild with Rake Simon Strandgaard wrote: > On 3/17/06, Simon Strandgaard wrote: >> depends on the .h files. > Anything smarter than converting makedepend to ruby, like this? Actually, its a bit easier than that ... but its a poorly documented area of Rake. Rake supports dependency files by importing them, like this: require 'rake/loaders/makefile' # Load the makefile dependency loader import '.depend.mf' # Import the dependencies. (notice the .mf extension, that tells Rake that the dependencies are in makefile format). So just create a task that builds the dependency files, similar to the above. file '.depend.mf' do sh "makedepend -f- -- #{CFLAGS} -- #{CPP_SOURCES} > .depend.mf" end After the Rakefile has been read, but before the user requested targets are built, Rake will check to see if any imported dependencies have been requested. If they have, rake will run any build targets for the dependencies (i.e. if the dependency file is out of date, it will rebuild it). It will then load the dependencies (no need to convert makefile style dependencies, rake will parse the file if the makefile loader has been required as shown above). The only gotcha in the scenario is that the dependency file rebuild cannot be triggered by any of the dependencies defined in the file (since the that file has not been loaded yet). -- -- Jim Weirich -- Posted via http://www.ruby-forum.com/.