explaingit

ninja-build/ninja

12,938C++Audience · developerComplexity · 2/5Setup · easy

TLDR

A small, extremely fast build tool that compiles software projects by only rebuilding files that changed. Usually used as the output target of CMake or another build generator rather than written by hand.

Mindmap

mindmap
  root((ninja))
    What it does
      Fast builds
      Incremental compile
      Build execution
    Works with
      CMake
      Python bootstrap
    Features
      Shell completion
      Editor integrations
      Cross-platform
    Audience
      C++ developers
      Build engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Speed up compile times on a large C++ project by switching from Make to Ninja as your build backend.

USE CASE 2

Use CMake to generate Ninja build files, then run fast incremental builds during development without waiting for full rebuilds.

USE CASE 3

Build Ninja from source using the included Python bootstrap script or CMake on Linux, Mac, or Windows.

Tech stack

C++PythonCMake

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Ninja is a build system: a tool that developers use to compile and assemble software projects. Its main design goal is speed. Build systems read a description of what needs to be compiled and in what order, then carry out those steps, ideally only rebuilding the parts that have actually changed since the last run. Ninja is intentionally small and simple. It does not aim to be a general-purpose scripting environment or a place to define complex project logic. Instead, it is typically used as the target output of a higher-level build generator. CMake, for example, can generate Ninja build files that Ninja then executes. This split means Ninja handles execution quickly while another tool handles the configuration complexity. The project is a single binary that runs on Linux, Mac, and Windows. Installation means placing that binary somewhere accessible, nothing more. Optional extras like shell tab completion and editor integrations for Emacs and Vim require copying a few files from the repository's misc directory. Building Ninja itself from source can be done two ways: a Python bootstrap script or CMake. The Python route generates the Ninja binary and a Ninja build file, which Ninja can then use to rebuild itself. The CMake route is straightforward for developers already using CMake. The README for this project is short and primarily directs readers to the full manual on the project website or the included documentation file for details on how to write Ninja build files and use Ninja's features.

Copy-paste prompts

Prompt 1
I'm using CMake for a C++ project and want to switch to Ninja as my build backend for faster compilation. Show me the cmake command to generate Ninja build files.
Prompt 2
My C++ project takes too long to build. How does Ninja decide what needs recompilation, and how do I configure it to skip unchanged files?
Prompt 3
Show me how to add Ninja shell tab completion for bash or zsh so I can autocomplete build targets in my terminal.
Prompt 4
I want to write a Ninja build file by hand for a small C project without using CMake. Show me the minimal ninja.build syntax to compile two source files into a binary.
Open on GitHub → Explain another repo

← ninja-build on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.