Add validation nodes to ninja

A common problem in the Android build is inserting rules that perform
some sort of error checking that doesn't produce any artifacts needed
by the build, for example static analysis tools.  There are a few
patterns currently used, both of which have downsides.

The first is to have a rule that depends on all of the static analysis
results.  This ensures they run, but requires running static analysis
over everything, and not just the active parts of the build graph.

The second is to insert the static analysis rule into the build graph
between the artifact producing rule and anything that depends on it,
often copying the artifact as the output of the static analysis rule.
This increases the critical path of the build, often reducing
parallelism.  In the case of copying the artifact, it also wastes
disk space.

This patch adds "validation nodes" to edges in Ninja.  A build
statement can specify validation nodes using "|@" in the edge
inputs.  The validation nodes are not used as an input to the edge
(the edge can run before the validation node is ready), but are
added to the initial nodes of the build graph whenever the edge
is part of the build graph.  The edge that outputs the validation
node can depend on the output of the edge that is being validated
if desired.

Test: ninja_test
Change-Id: Ife27086c50c1b257a26509373199664680b2b247
16 files changed
tree: 39e12abe514f4794fa3d87ccec2a0c31c9ed3922
  1. .github/
  2. doc/
  3. misc/
  4. src/
  5. windows/
  6. .clang-format
  7. .clang-tidy
  8. .editorconfig
  9. .gitignore
  10. appveyor.yml
  11. CMakeLists.txt
  12. configure.py
  13. CONTRIBUTING.md
  14. COPYING
  15. README.md
  16. RELEASING
README.md

Ninja

Ninja is a small build system with a focus on speed. https://ninja-build.org/

See the manual or doc/manual.asciidoc included in the distribution for background and more details.

Binaries for Linux, Mac, and Windows are available at GitHub. Run ./ninja -h for Ninja help.

Installation is not necessary because the only required file is the resulting ninja binary. However, to enable features like Bash completion and Emacs and Vim editing modes, some files in misc/ must be copied to appropriate locations.

If you're interested in making changes to Ninja, read CONTRIBUTING.md first.

Building Ninja itself

You can either build Ninja via the custom generator script written in Python or via CMake. For more details see the wiki.

Python

./configure.py --bootstrap

This will generate the ninja binary and a build.ninja file you can now use to build Ninja with itself.

CMake

cmake -Bbuild-cmake
cmake --build build-cmake

The ninja binary will now be inside the build-cmake directory (you can choose any other name you like).

To run the unit tests:

./build-cmake/ninja_test