I’ve got a top-level Rakefile that builds some C files. So, I’ve got a
rule in there for building .c files to .o files. This rakefile has its
own global variables, like $CFLAGS for example.
rule ‘.o’ => ‘.c’ do |t|
cmd = “cc #{$CFLAGS} #{$INCLUDES} -c -o #{t.name} #{t.source}”
sh cmd
end
I’ve also got a subdirectory with a C file in it that needs slightly
different value of $CFLAGS to build. I’ve got a rule in that Rakefile
as well, and it looks exactly like the one in the top-level rakefile.
The C file in the subdir needs to be built before the top-level
Rakefile can do its jobs of building other things.
My guess is that just using:
require 'subdir/Rakefile'
would botch things up, since I’m using a global $CFLAGS.
I’d think I’d like to just do something this in the top-level Rakefile:
task :default => [:build_other_c_file] do |t|
sh “cd subdir; rake”
end
Is that the way multi-rakefile projects usually do it?
Although it’s “considered harmful” for large projects, I don’t mind
doing something like how make recursivly decends into subdirectories
to make dependencies. How’s that usually done with rake?
I read one of Jim’s posts relating to this
http://rubyforge.org/pipermail/rake-devel/2005-December/000182.html
but don’t know exactly how I’d go about building a “unified dependency
graph” as he recommends.
Thanks,
—John