Top Qs
Timeline
Chat
Perspective
Ninja (build system)
Free build automation software From Wikipedia, the free encyclopedia
Remove ads
Ninja is a 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.[4]
Remove ads
Build system
In essence, Ninja is meant to replace Make, which is slow when performing incremental (or no-op) builds.[5] 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.[6] It's also used to build Android (via Makefile translation by Kati),[7] and is used by most developers working on LLVM.[8]
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[9] are popular build management tools that support creating build files for Ninja.[10]
Remove ads
Example
Below is an example of a Ninja build file that compiles two C source files (source1.c and source2.c) into object files and then links them into an executable called myprogram. It defines two rules: one for compiling (cc) and one for linking (link):
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.c
build source2.o: cc source2.c
build myprogram: link source1.o source2.o
Remove ads
References
External links
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads
