Translate

Archives

Chronium Ninja Build System

If you have even had to build the Chromium browser from source using GNU Make, you will know that it is a very slow process even on a 4 core system.

Ninja is a build system written by Evan Martin, who works for Google and is a Chrome developer, with the specific goal of improving the edit-compile cycle time. It currently only works on Linux. It can be dropped into a Chrome or Chromium build and behaves very similar to the GNU Make utility except it builds things much faster than make can. Typically you should use the Gold linker with ninja and have more than 1024 file handles available. Combine ninja with the Gold linker on Linux and you have a build system that is 5 or more times faster than using GNU Make and the traditional GNU BFD linker.

There are a number of steps to using ninja. First, you need to download and build ninja on your build platform.

$ git clone git://github.com/martine/ninja.git
$ cd ninja; ./bootstrap.sh

You should then add ninja to your PATH.

You also require gyp (Generate Your Project) support for ninja.

$ cd .../src/tools
$ mv gyp gyp-non-ninja
$ git clone git://github.com/martine/gyp.git

Next you need to reconfigure the build system, i.e. gyp, to use ninja.

$ export GYP_GENERATORS='ninja'
$ export GYP_DEFINES='disable_nacl=1'   # if you do not want nacl
$ cd .../src
$ ./build/gyp_chromium -Dwerror= -Gconfig=Release  # replace with Debug if you want debug build


The gyp-generated build files live in the …/src/[Release|Debug]/out directory.

To start a Release build of Chromium:

$ cd /path/to/chrome/src
$ ninja -C out/Release chrome


Replace Release with Debug if you want to build a debug version of Chromium.

I suggest you watch the load average on your build platform using top or a similar utility while you are running a ninja-enabled build of Chromium. You will be impressed!

Comments are closed.