ninja

small, fast build system

TLDR

Build project
$ ninja
Build specific target
$ ninja [target]
Build with multiple jobs
$ ninja -j [8]
Build in a different directory
$ ninja -C [build_dir]
Clean build
$ ninja -t clean
Dry run
$ ninja -n
Verbose output
$ ninja -v
Keep going after errors
$ ninja -k [0]
Use specific build file
$ ninja -f [build.ninja]
Show build graph
$ ninja -t graph [target]

SYNOPSIS

ninja [options] [targets]

DESCRIPTION

ninja is a small, fast build system closest in spirit to Make. It focuses on speed and correctness, taking a different approach by having its input files be generated by a higher-level build system rather than written by hand.Build files (build.ninja) are typically generated by CMake, Meson, or GN. Ninja was designed to replace Make as the build executor for large projects like Chromium.

PARAMETERS

TARGETS

Build targets.
-j N
Run N jobs in parallel (0 means infinity) [default=number of CPUs].
-f FILE
Specify input build file [default=build.ninja].
-C DIR
Change to DIR before doing anything else.
-v
Show all command lines while building.
-n
Dry run (don't run commands but act like they succeeded).
-k N
Keep going until N jobs fail (0 means infinity) [default=1].
-l N
Do not start new jobs if the load average is greater than N.
-t TOOL
Run a subtool (use -t list to list subtools).
-d MODE
Enable debugging (use -d list to list modes).
-w FLAG
Adjust warnings (use -w list to list warnings).
--version
Print ninja version.
--help
Display help information.

INSTALL

sudo apt install ninja-build
sudo dnf install ninja-build
sudo pacman -S samurai
sudo apk add samurai
sudo zypper install samurai
brew install samurai
nix profile install nixpkgs#samurai

CAVEATS

Build files are not typically hand-written but generated by a meta-build system. Ninja has minimal features compared to Make by design. Default parallelism is based on the number of available CPUs.

HISTORY

Ninja was created by Evan Martin at Google for building Chrome, released in 2012.

SEE ALSO

cmake(1), meson(1), make(1)