| mhat ( @ 2006-06-20 01:12:00 |
| Entry tags: | geek, rake, ruby |
recursive make considered harmful
I've spent a few hours the last few work days and [gasp] even a evening or two working on replacing Opus's awful ksh+make based build system with ruby rake. Ever since I started using the Opus build system I've wanted to fix it.
It was written with a quickness back in the day. The guy who wrote it didn't know the difference between ksh, bash, tcsh, etc. He picked ksh because it sounded good and he thought that all configure scripts were written in ksh. He missed the whole autoconf, automake tool chain bote. We have a scattering of Makefiles and Makefile.PLs that get glued together into something that more or less works albeit slowly.
Last December I took a stab at replacing all that with ANT. I had previously looked at Cons and SCons but I didn't see a lot of love there. I recall both being fairly C/C++ oriented. Now, the smart reader might be thinking ``Wait, you're saying SCons was out because it was to "C/C++"-ish but ANT, which is a purely Java centric ball of hate, was okay?'' -- Yeah, it was a bad idea. XML markup does not a good programming syntax make. Worse yet to do anything even remotely useful with ANT I had to use some 3rd party modules to enable in-line Java and [I kid you not] Javascript in ANT's XML files.
Enter Ruby Rake! I'm not quite done replacing ksh+make but I've made a pretty good run of it over a few hours. Handling about 85% of the source tree I've improved "build" time from ~7 minutes to ~4 seconds. Since our code is mostly run-time compiled interpreted languages "building" really means "copying". Our old build system is slow because (a) there are a lot of directories and (b) make is called recursively for each.
Rake isn't perfect but it seems to do a better job of not being language specific than SCons or ANT. I've seen examples of folks using it with Java and C/C++ so that's a good sign. I think I'm using it somewhat differently that most people though, so hopefully once I have time to pull my notes out of OmniOutliner I'll be able to publish a short tutorial. I have one Rakefile at the base of the source tree. Running ``rake'' will recurse up the directory tree until it either finds a Rakefile or the root and gives up. My Rakefile then figures out where it is running from and only includes dependent tasks that make sense. For example if you are in GUI it won't bother looking at anything in DBI. Next rather than installing everything all the time it will only install files from the current directory down, which is basically what you would expect/want from recursive-make on here with out the recursive or the make. Spam is generally limited to listing only the files that are being installed/changed which is still a little noisy on the initial build but subsequent builds are quiet and informative.