Lines Matching full:ninja
1 The Ninja build system
9 Ninja is yet another build system. It takes as input the
13 Ninja joins a sea of other build systems. Its distinguishing goal is
15 http://neugierig.org/software/chromium/notes/2011/02/ninja.html[my
19 after changing one file. Ninja is under a second.
24 Where other build systems are high-level languages, Ninja aims to be
32 Ninja contains the barest functionality necessary to describe
36 Instead, Ninja is intended to be used with a separate program
42 build a debug or release-mode binary?" belong in the `.ninja` file
48 Here are the design goals of Ninja:
73 generate your ninja files using another program_. This is how we
76 * built-in rules. _Out of the box, Ninja has no rules for
80 the program that generates the ninja files_.
85 To restate, Ninja is faster than other build systems because it is
86 painfully simple. You must tell Ninja exactly what to do when you
87 create your project's `.ninja` files.
92 Ninja is closest in spirit and functionality to Make, relying on
100 In contrast, Ninja has almost no features; just those necessary to get
102 ninja input files. Ninja by itself is unlikely to be useful for most
105 Here are some of the features Ninja adds to Make. (These sorts of
109 * Ninja has special support for discovering extra dependencies at build
136 Using Ninja for your project
139 Ninja currently works on Unix-like systems and Windows. It's seen the
143 If your project is small, Ninja's speed impact is likely unnoticeable.
144 (However, even for small projects it sometimes turns out that Ninja's
147 edit-compile cycle time of your project already then Ninja won't help.
150 featureful than Ninja itself. For some recommendations: the Ninja
152 in Ninja's design, and thinks https://github.com/apenwarr/redo[redo]'s
155 Ninja's benefit comes from using it in conjunction with a smarter
160 node.js), as well as Google Fuchsia. gn can generate Ninja files for
164 can generate Ninja files on Linux as of CMake version 2.8.8. Newer versions
165 of CMake support generating Ninja files on Windows and Mac OS X too.
167 https://github.com/ninja-build/ninja/wiki/List-of-generators-producing-ninja-build-files[others]:: …
171 Running Ninja
174 Run `ninja`. By default, it looks for a file named `build.ninja` in
184 `ninja -h` prints help output. Many of Ninja's flags intentionally
185 match those of Make; e.g `ninja -C build -j 20` changes into the
187 Ninja defaults to running commands in parallel anyway, so typically
194 Ninja supports one environment variable to control its behavior:
208 `%e`:: Elapsed time in seconds. _(Available since Ninja 1.2.)_
209 `%E`:: Remaining time (ETA) in seconds. _(Available since Ninja 1.12.)_
210 `%w`:: Elapsed time in [h:]mm:ss format. _(Available since Ninja 1.12.)_
211 `%W`:: Remaining time (ETA) in [h:]mm:ss format. _(Available since Ninja 1.12.)_
212 …ge (in ppp% format) of time elapsed out of predicted total runtime. _(Available since Ninja 1.12.)_
222 The `-t` flag on the Ninja command line runs some tools that we have
223 found useful during Ninja's development. The current tools are:
234 ninja -t browse --port=8000 --no-browser mytarget
241 ninja -t graph mytarget | dot -Tpng -ograph.png
244 In the Ninja source tree, `ninja graph.png`
245 generates an image for Ninja itself. If no target is given generate a
249 like +ninja -t targets rule _name_+ it prints the list of targets
252 +ninja -t targets depth _digit_+ it
256 +ninja -t targets depth 1+ is assumed. In this mode targets may be listed
257 several times. If used like this +ninja -t targets all+ it
267 _Available since Ninja 1.11._
276 If used like +ninja -t clean -r _rules_+ it removes all files built using
284 build file. _Available since Ninja 1.10._
291 _Available since Ninja 1.2._
294 target, show just the target's dependencies. _Available since Ninja 1.4._
309 _Available since Ninja 1.11._
311 `recompact`:: recompact the `.ninja_deps` file. _Available since Ninja 1.4._
314 file. _Available since Ninja 1.10._
317 to pass to +ninja -t targets rule _name_+ or +ninja -t compdb+. Adding the `-d`
325 ninja -t msvc -e ENVFILE -- cl.exe <arguments>
337 ninja -t msvc -o DEPFILE [-p STRING] -- cl.exe /showIncludes <arguments>
345 Note that Ninja supports this natively now, with the use of `deps = msvc` and
346 `msvc_deps_prefix` in Ninja files. Native support also avoids launching an extra
350 `wincodepage`:: Available on Windows hosts (_since Ninja 1.11_).
358 Additional lines may be added in future versions of Ninja.
366 Writing your own Ninja files
370 Ninja files yourself: for example, if you're writing a meta-build
376 Ninja evaluates a graph of dependencies between files, and runs
379 Make, Ninja is very similar.
381 A build file (default name: `build.ninja`) provides a list of _rules_
394 Here's a basic `.ninja` file that demonstrates most of the syntax.
409 build files readable (debuggable), Ninja supports declaring shorter
451 output files are missing or when the inputs change, Ninja will run the
491 If the top-level Ninja file is specified as an output of any build
492 statement and it is out of date, Ninja will rebuild and reload it
495 Generating Ninja files from code
498 `misc/ninja_syntax.py` in the Ninja distribution is a tiny Python
499 module to facilitate generating Ninja files. It allows you to make
500 Python calls like `ninja.rule(name='foo', command='bar',
519 This makes `ninja foo` build the longer path. Semantically, the
533 it does not exist. Without a phony build statement, Ninja will report
548 By default, if no targets are specified on the command line, Ninja
551 A default target statement causes Ninja to build only a given subset
565 This causes Ninja to build the `foo`, `bar` and `baz` targets by
570 The Ninja log
573 For each built file, Ninja keeps a log of the command used to build
574 it. Using this log Ninja can know when an existing output was built
587 _Available since Ninja 1.2._
589 Ninja version labels follow the standard major.minor.patch format,
592 behaviors. Your `build.ninja` may declare a variable named
593 `ninja_required_version` that asserts the minimum Ninja version
601 introduced in Ninja 1.1 (perhaps the `pool` syntax), and that
602 Ninja 1.1 or greater must be used to build. Unlike other Ninja
607 Ninja always warns if the major versions of Ninja and the
617 works in a similar way) correct Ninja has some extra functionality.
623 and Ninja can use that to get its dependencies perfect.
631 When loading these special dependencies, Ninja implicitly adds extra
643 To bring this information into Ninja requires cooperation. On the
644 Ninja side, the `depfile` attribute on the `build` must point to a
645 path where this data is written. (Ninja only supports the limited
662 _(Available since Ninja 1.3.)_
668 Ninja 1.3 can instead process dependencies just after they're generated
669 and save a compacted form of the same information in a Ninja-internal
672 Ninja supports this processing in two forms.
676 cause Ninja to process the `depfile` immediately after the
684 to its stdout. Ninja then filters these lines from the displayed
706 _Available since Ninja 1.1._
720 No matter what pools you specify, ninja will never run more concurrent jobs
761 _Available since Ninja 1.5._
765 standard input, output and error streams provided to Ninja, which are
770 While a task in the `console` pool is running, Ninja's regular output (such
775 Ninja file reference
793 Implicit outputs _(available since Ninja 1.7)_ may be added before
812 Ninja is mostly encoding agnostic, as long as the bytes Ninja cares
873 `builddir`:: a directory for some Ninja output files. See <<ref_log,the
877 `ninja_required_version`:: the minimum version of Ninja required to process
898 `deps`:: _(Available since Ninja 1.3.)_ if present, must be one of
904 `msvc_deps_prefix`:: _(Available since Ninja 1.5.)_ defines the string
913 `dyndep`:: _(Available since Ninja 1.10.)_ Used only on build statements.
938 `restat`:: if present, causes Ninja to re-stat the command's outputs
944 `rspfile`, `rspfile_content`:: if present (both), Ninja will use a
969 On Unixes, commands are arrays of arguments. The Ninja `command`
976 On Windows, commands are strings, so Ninja passes the `command` string
983 prefixing the command with `cmd /c`. Ninja may error with "invalid parameter"
1000 Ninja 1.7)_. The semantics are identical to explicit outputs,
1016 Ninja doesn't know how to build them, the build is aborted.
1048 relative path, pointing to the same file, are considered different by Ninja.
1054 _Available since Ninja 1.11._
1058 on the Ninja command line) whenever the build line is a transitive
1110 _(Available since Ninja 1.6)_
1112 The `subninja` keyword, used to include another `.ninja` file,
1117 To include another `.ninja` file in the current scope, much like a C
1141 _Available since Ninja 1.10._
1159 As soon as `foo` is finished Ninja will read it to load dynamically
1161 implicit inputs and/or outputs. Ninja will update the build graph
1169 as <<ref_ninja_file,ninja build files>> and have the following layout.
1193 to build statements in the <<ref_ninja_file,ninja build file>> that name the
1236 Ninja will load this file to add `foo.mod` as an implicit output of
1248 of the tarball and cannot be spelled out explicitly in the ninja build file.
1273 Ninja will load this file to add `file1.txt` and `file2.txt` as implicit
1276 extracted again. The `restat` binding tells Ninja to tolerate the fact