From: Jim Weirich Date: 2003-03-22T22:19:41+09:00 Subject: Re: Rake problem? On Sat, 2003-03-22 at 05:30, Brian Candler wrote: > With rake-0.2.1 I can't duplicate the original problem, i.e. I can set it > back to "main" => [:obj] and it works: :-) [... thoughts on object files and prerequisites elided ...] > Hmm, how about some sugar: > #{t.sources('.o')} These are some good thoughts. Before I make any changes in this area, I'm going to think the problem through and experiment with Rake on projects that are a bit larger. The suggestion sounds promising however. Thanks. > One other idea. If you have a large project with components in > subdirectories, it would be really cool if you could have a top-level > Rakefile which includes the sub-Rakefiles and generates a single dependency > graph automatically. As far as I can see all you would need is something > like > > require 'subdir/Rakefile' > > except that all the files/dependencies would need 'subdir' prepended to them > in the global dependency graph (perhaps using a global $prefix). Or maybe the > graph should be built with only absolute pathnames in it? so > file "foo" > would generate basename($0)+"foo" ? > > There's an excellent article here about why this could work extremely well > for large projects: > http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html In general, I prefer to see a single Rakefile at the top of a project tree, rather than a bunch of little rakefiles scattered about. In part, this preference was inspired by the "Recursive Make Considered Harmful" article that you reference (although its been a long time since I read it, I should review it again in light of Rake). If all we are doing with the sub-directory rakefile is record dependencies, then there are several ways of handling it. For example (1) Record dependencies in a rakefile in each subdirectory and recursively include them. (2) Calculate and append the dependencies to a master Rakefile. (3) Calculate and store the dependencies in a single file, but separate from the master Rakefile. (4) Recalculate the dependencies dynamically each time Rake is invoked. (5) Calculate and store the dependencies in a serialized format (e.g. using Marshall or PStore). I've done both (2) and (3) using Makefiles and both would work with Rake. (4) is nice that you never have to ask for the dependecies to be regenerated, but I'm afraid that recalculating the dependencies on each invocation would be annoyingly slow. (5) is an interesting idea that currently can't be done in Make, but might require some refactoring so that dependencies could be stored outside of task definitions. I'm not ready to dictate which method can be used, but am willing to make sure that Rake supports whatever style the developer chooses. > P.S. I'm not sure I like the searching for Rakefile in parent directories. > If I am in doc/example and type 'rake' then I get the testsuite built; it's > a bit unexpected! I got the idea from ant. In real life it would be less confusing because (1) you would have only a single Rakefile and running rake would consistently use it no matter where you are in the project tree, or (2) you have multiple Rakefiles, but they are named the same so you always get the most local version. Thanks for the feedback. You've certainly given me some things to think about. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)