Ninja (build system) explained

Ninja
Developer:Evan Martin
Released:[1]
Latest Release Version:
Programming Language:C++, Python
Operating System:Linux, macOS, Windows
Genre:Software development tools
License:Apache License 2.0[2]

Ninja is a small build system developed by Evan Martin,[3] a Google employee. Ninja has a focus on speed and it differs from other build systems in two major respects: it is designed to have its input files generated by a higher-level build system, and it is designed to run builds as fast as possible.

Build system

In essence, Ninja is meant to replace Make, which is slow when performing incremental (or no-op) builds.[4] This can considerably slow down developers working on large projects, such as Google Chrome which compiles 40,000 input files into a single executable. In fact, Google Chrome is a main user and motivation for Ninja.[5] It's also used to build Android (via Makefile translation by Kati),[6] and is used by most developers working on LLVM.[7]

In contrast to Make, Ninja lacks features such as string manipulation, as Ninja build files are not meant to be written by hand. Instead, a "build generator" should be used to generate Ninja build files. Gyp, CMake, Meson, and gn[8] are popular build management software tools which support creating build files for Ninja.[9]

Example

rule cc command = gcc -c -o $out $in description = CC $out rule link command = gcc -o $out $in description = LINK $out build source1.o: cc source1.cbuild source2.o: cc source2.cbuild myprogram: link source1.o source2.o

External links

Notes and References

  1. Web site: Martin. Evan. Google Groups: ninja-build. 18 June 2017.
  2. Web site: COPYING . Github . 5 September 2019.
  3. Web site: Google man open sources Chrome build system.
  4. Web site: Röthlisberger. David. The Ninja build tool. LWN. 18 June 2017.
  5. Web site: Ninja. The Performance Of Open Source Applications. 18 June 2017.
  6. Web site: aosp mailing list.
  7. Web site: LLVM documentation.
  8. Web site: gn - Git at Google.
  9. Web site: Kitware. cmake Documentation. 18 June 2017.