๐Ÿฅท

Ninja

Ninja is a small, extremely fast build system originally created by Google, tied for the #37 most-used build tool in developer surveys at roughly 5.2% usage share. Unlike Make, Ninja isn't meant to be written by hand โ€” other build systems like CMake generate its build.ninja files for you. It's used because it's optimized purely for the speed of incremental rebuilds, which matters enormously in huge C/C++ codebases like Chromium and LLVM.

Quick facts
Type: Low-level build tool / build-file executor
Made by: Google (open-source project)
License: Free / open-source (Apache 2.0)
Platforms/Hosting: Cross-platform (Windows, macOS, Linux)
Primary use case: Executing generated build graphs as fast as possible, especially for large C/C++ projects
Jump to: ExampleGetting startedBest for

Example

A minimal hand-written build.ninja file showing a rule and a build edge โ€” in practice, CMake or GN would generate this for you automatically.

# build.ninja
rule cc
  command = gcc -c $in -o $out
  description = Compiling $in

build main.o: cc main.c
build app: link main.o
  command = gcc main.o -o app

Getting started

Most developers never invoke Ninja directly โ€” they generate the build files with CMake, then let Ninja execute them.

# install Ninja (or via apt/brew/choco)
pip install ninja

# tell CMake to generate Ninja build files instead of Makefiles
cmake -G Ninja -S . -B build

# run the fast incremental build
ninja -C build
Best for: Large, performance-sensitive C/C++ (or Rust/Go) codebases where rebuild speed matters constantly โ€” teams that already use CMake or another generator and just need the fastest possible execution backend.