Support always-dirty Ninja actions

Always-dirty phony targets are those which do not have any inputs: "build alias: phony".
Ninja specification says:
"phony can also be used to create dummy targets for files which may not exist at build time. If a phony build statement is written without any dependencies, the target will be considered out of date if it does not exist. Without a phony build statement, Ninja will report an error if the file does not exist and is required by the build."
So actually Ninja leaves the possibility that the phony target file *may* exist, and then it is not always dirty.
However in our case, we in general do not allow explicit expression of the circular dependency on self-outputs (instead, action cache should determine whether the outputs already exist and do not have to be rebuilt), so we will interpret phony actions without inputs as always dirty.

All usual direct dependants of those actions automatically also always-dirty (but not
the transitive dependants: they should check whether their computed inputs have changed).
As phony targets are not performing any actions,

*all phony transitive dependants of always-dirty phony targets are themselves always-dirty.*

That is why we can compute the always-dirty flag for the phony targets, and use it for marking their direct non-phony dependants as actions to be executed unconditionally.

Closes #10778.

PiperOrigin-RevId: 295106358
7 files changed
tree: d030469df501e50dd7f2b0ba53e34ea4a2f645df
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .bazelrc
  9. .gitattributes
  10. .gitignore
  11. AUTHORS
  12. BUILD
  13. CHANGELOG.md
  14. CODEOWNERS
  15. combine_distfiles.py
  16. combine_distfiles_to_tar.sh
  17. compile.sh
  18. CONTRIBUTING.md
  19. CONTRIBUTORS
  20. distdir.bzl
  21. ISSUE_TEMPLATE.md
  22. LICENSE
  23. README.md
  24. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status