Improve error messaging for constraints violations.

1) Break up dense lines with clearer pretty-printing.
2) When a violation happens because of a select(), mention
   both the target with the select (as before) *and*
   the dep that the select() chose.
3) Integrate this messaging into --target_environment violations,
   which currently provide no info about the root cause.

Examples:

-------------------------------------
select() + compatible_with violation:
-------------------------------------
Before:
  ERROR: /workspace/testapp/BUILD:41:1: in cc_binary rule //testapp:top: the current command-line flags disqualify all supported environments because of incompatible select() paths:
 environment: //constraints:p removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1)

After:
  ERROR: /workspace/testapp/BUILD:41:1: in cc_binary rule //testapp:top: the current command line flags disqualify all supported environments because of incompatible select() paths:

    environment: //constraints:p
      removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1)
      which has a select() that chooses dep: //testapp:glib
      which lacks: //constraints:p.

-------------------------------------
select() + --target_environment=//constraints:p violation:
-------------------------------------
Before:
  ERROR: This is a restricted-environment build.
   - //testapp:top does not support required environment //constraints:p

After:
  ERROR: This is a restricted-environment build.

  //testapp:top does not support:
    environment: //constraints:p
      removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1)
      which has a select() that chooses dep: //testapp:g
      which lacks: //constraints:p

Fixes: #5795
PiperOrigin-RevId: 207910308
6 files changed
tree: f4408c5b57fa270456deef047f512e6fb59ffa17
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. AUTHORS
  11. BUILD
  12. CHANGELOG.md
  13. CODEOWNERS
  14. combine_distfiles.py
  15. combine_distfiles_to_tar.sh
  16. compile.sh
  17. CONTRIBUTING.md
  18. CONTRIBUTORS
  19. distdir.bzl
  20. ISSUE_TEMPLATE.md
  21. LICENSE
  22. README.md
  23. 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 only rebuilds 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

Bazel is released in ‘Beta’. See the product roadmap to learn about the path toward a stable 1.0 release.