I am writing a Rakefile for a C ++ project. I want it to automatically identify #includes, forcing to rebuild object files that depend on the modified source files. I have a working solution, but I think it could be better. I am looking for offers for:
- Suggestions for improving my function.
- Libraries, gems, or tools that do the work for me
- Links to cool C ++ Rakefiles that I have to check out that do similar things
Here is what I still have. This is a function that returns a list of dependencies defined by the source file. I am loading the source file for this object file and I need a list of files that will force me to rebuild my object file.
def find_deps( file )
deps = Array.new
cmd = "grep -r -h -E \"#include\" #{file}"
includes = `#{cmd}`
includes.each do |line|
dep = line[ /\.\/(\w+\/)*\w+\.(cpp|h|hpp)/ ]
unless dep.nil?
deps << dep
deps += find_deps( dep )
end
end
return deps
end
, :
#include "./Path/From/Top/Level/To/My/File.h"
#include "../../../Path/From/Top/To/My/File.h"
, include . , .