Sunday, August 24, 2008

rake for c++

In the c++ program I've been working on, shessiond, I had been using GNU make. Unfortunately make blows. I got it to build, but it wasn't doing incremental builds, it was rebuilding everything everytime. This worked for a while because it was small. Now it's growing larger and I finally got sick of full rebuilds everytime.

I considered mucking with the Makefile to get it to work. I even have the GNU Make book. But, it isn't much different than a longer version of the make man page.

I also looked at scons. At first it looked like it had good documentation, but it's not as much or as helpful as it first appears. There was no obvious, simple example of compiling source objects _and then_ compiling those objects into an executable. Also, they seemed to have an odd build system that they almost threaten you with on the developer page.

So Rake seemed good. I decided this because it's also hosted on github. Most Rake documentation is for using it with Ruby. The few C++ examples I could find were pretty realistic.
* http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
* http://www.ruby-forum.com/topic/58444

After a while of messing around, I finally got it working. Most of my confusion here came from the Ruby syntax, which I think I'll adjust to. And, as opposed to the Makefile, when I got the Rakefile working, I actually understood the important parts of how it works.

The one thing I'm still trying to resolve is an issue with the build paths. I tried to configure it to build my source files into a separate obj directory. This works for my files in the src/ directory, but breaks when I try to compile test code in the test/ directory. It seems a solvable problem though, and far less intimidating than trying to figure it out with make.

The other remaining issue is dependencies on headers. This is covered in the link above though, so I expect to get it working once I actually try to do it.

No comments: