[Rake-devel] problem importing deps

Shea Martin shea08 at eastlink.ca
Wed Jan 17 16:51:25 EST 2007

Shea Martin wrote:
> My source tree looks like this.
> source/dir/file1.cpp
> source/dir/file1.h
> source/another_dir/file2.cpp
> source/another_dir/file2.h
> I build to a build directory, which afeter a build looks like this:
> build/dir/file1.o
> build/another_dir/file2.o
> build/another_dir/file2.mf
> my .cpp.o rule looks like this:
> rule '.o' => [ proc { |target| target.pathmap( 
> "%{^#{$config.builddir},#{$config.srcdir}}X.c" ) } ] do | task |
>     sh( "gcc -c -o #{task.name} #{task.source}
>     sh( "gcc -MM -o #{task.name.ext('.mf')} #{task.source}" )
> end
> I import the .mf files using 'import'.
> Note: rake fails to import the dep files if I name them anything other 
> than .mf.  It is pretty common practise to name these files .d, but rake 
> chokes on them then, assuming they are ruby files...
> build/dir/file1.mf would look like this:
> file1.o: source/dir/file1.h source/another_dir.h c:/path/to/API/hdr.h
> rake -P then shows the deps like this:
> file1.o as "source/dir/file1.h source/another_dir.h c"
> So the import is choking on the colon in the path of hdr.h.  This is the 
> first problem. I can work around it by filtering the absolute paths out 
> of the .mf file, as I really don't want to do dep checking on files out 
> of my local tree anyway.
> The second problem is that when I build a file I do it like this:
> rake build/dir/file1.o.  The dep checking is never done because the .mf 
> file is specifies file.o not build/dir/file.o.  I am not sure what to do 
> about this one...
> It looks like I may be better just to write my own dep checking tool...
> Thought, tips?
> ~S

I wrote a function which filters the output of gcc -MM to be compatible 
with rake.  It makes all paths relative, so rake does not choke on c:\, 
and also strips out api/SDK deps, so in the end it made my build faster 
anyway. :-)



More information about the Rake-devel mailing list