Build Chromium in Eclipse with Ninja and Clang

Because the Chromium project’sĀ wiki suggests to use Ninja to speed up the build process, I decided to give it a try. But as I’m working with Eclipse, I would be annoyed by having to switch between Eclipse and a console every time I want to recompile. Especially as it works fine with make. Combining some hints from different pages finally lead to an Eclipse build configuration which works just as convenient.

For this solution I assume that you already have a working make setup for Eclipse (build instructions, Eclipse setup).

Setup Ninja and Clang

Clang is not part of the Chromium checkout by default, thus you must, from the 'src' directory of your checkout, execute:
tools/clang/scripts/update.sh

Afterwards, gyp will recreate the build files for Ninja and Clang with the following command:
GYP_GENERATORS=ninja GYP_DEFINES=clang=1 ./build/gyp_chromium

Next, before starting the compilation with Ninja and Clang, this page suggests to remove the output directory to prevent confusion between Ninja and make:
rm -rf out/Debug

To compile with the new setup, invoke:
ninja -C out/Debug chrome

Make Eclipse using Ninja

If the steps above are taken successfully and Ninja builds from the console, it is time to adapt the build settings for Eclipse (I’m using 3.7).

Open the project properties and navigate to the ‚C/C++ Build‘ option. In the tab ‚Builder Settings‘, uncheck ‚Use default build command‘ and set ‚ninja -C out/Debug‚ as the build command. The build directory below should be set to ‚${workspace_loc:/chromium/src}‚, i.e. point to the src directory of the checkout, if this is not the case already.

Switch to tab ‚Behaviour‘ and uncheck ‚Use parallel build‘ – Ninja uses all cores by default – or set a number of jobs you like. If not checked, checkĀ ‚Build (Incremental build)‘ and in either case set it to ‚chrome‚.

With this settings, Eclipse now uses Ninja and Clang to build the project. If you encounter problems with the PATH variable, the Chromium wiki suggests to manually set it in Eclipse.

Leave a comment

Your comment

(required)