Tuesday, August 26, 2014

What happened to the build process for Couchbase 3.0?

It's been a long time since my last blog post, so I figured I should write up a short summary of some of the things I've been working on. The upcoming Couchbase 3.0 server contains a lot of new cool stuff, but I'm going to dedicate this blog post to something you don't see when you install the product.

One of the most important tasks when developing software is to have an efficient system to build, test and debug the stuff you're developing. The better the build, test & debug cycle you've got, the faster you should be implementing new features and verify that they work as expected. If you look at the history behind Couchbase, you'll see that it started out as NorthScale. In the early days "we" used mac laptops for developent (except for me who used my beloved Solaris desktop), so we used GNU autotools and make to build the system. In order to support Windows we built the stuff on Windows by using MinGW and Cygwin.

Over the years its been time consuming and hard to maintain the build process on Windows, and although MinGW/Cygwin offers this Unix abstraction layer it is "dead slow" during the compilation phase under GNU autotools. Another "problem" by using gcc on Windows is that it didn't integrate nicely with MSVC, so you had to revert to gdb if you wanted to debug stuff. In order to solve these problems I spent a lot of time moving our existing build process off GNU Autotools over to CMake, and re implement all of the code assuming that we're running on a Unix/Linux system so that we could build everything with MSVC. When I started out MSVC didn't support C99, and we had _a lot_ of code using C99. Reverting that back to C89 isn't hard, just time consuming (I didn't want to add an extra step in the build chain on Windows trying to do that automatically). When I was basically done with the conversion Microsoft finally released MSVC 2013 with partial support for C99 ;-). I even ported "all" of our unit tests so that all of them are supposed to work on all platforms (earlier we had a subset of tests implemented in Perl etc that only ran on Unix/Linux etc).

I'm not going to say that CMake is the magic pill that solves all of our problems, because it has its own set of "challenges" we've been working around. That being said our build process is a lot easier and a lot faster on all of our supported platforms. Before the conversion I wouldn't recommend people to try to build Couchbase from source on Windows themselves, but after the conversion it is pretty easy build on a lot of platforms. As part of setting up my builders at home I've added the steps to a readme so you should be able to test yourself :-)

Happy hacking!