Make a rule's `Location` consistent regardless of whether `generator_*` attributes are explicitly set.

The logic that detects whether `generator_name` or `generator_function` are already set dates back to python pre-processing and is no longer relevant, but it's still being used by rules that explicitly set one or both of these attributes. Remove this check to ensure that the location is determined consistently: from the outermost frame of the call stack.

Deriving the location directly from the call stack opens up the opportunity to avoid storing the `<toplevel>` frame in `CallStack`, since it is the same as the location.

Explicitly set `generator_*` attributes seems to happen in practice when attributes are copied from `native.existing_rule`. I will look into whether this can be cleaned up or hand it off if there's a volunteer.

RELNOTES: The location of rules that explicitly specify `generator_name` and/or `generator_function` attributes (typically because they are incidentally copied from `native.existing_rule()`) is now the top-level call in the `BUILD` file, which is consistent with rules that do not explicitly specify these attributes.
PiperOrigin-RevId: 521878142
Change-Id: Ie8fb7fa9c4bef9137f6e7d7a5c50fb049024a585
2 files changed
tree: a49e4b9235fb8a5e28deedae9fedc584af29feb2
  1. .bazelci/
  2. .github/
  3. examples/
  4. scripts/
  5. site/
  6. src/
  7. third_party/
  8. tools/
  9. .bazelrc
  10. .bazelversion
  11. .gitattributes
  12. .gitignore
  13. AUTHORS
  14. BUILD
  15. CHANGELOG.md
  16. CODE_OF_CONDUCT.md
  17. CODEOWNERS
  18. combine_distfiles.py
  19. combine_distfiles_to_tar.sh
  20. compile.sh
  21. CONTRIBUTING.md
  22. CONTRIBUTORS
  23. distdir.bzl
  24. distdir_deps.bzl
  25. LICENSE
  26. maven_install.json
  27. MODULE.bazel
  28. README.md
  29. SECURITY.md
  30. WORKSPACE
  31. WORKSPACE.bzlmod
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

Reporting a Vulnerability

To report a security issue, please email security@bazel.build with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.

Contributing to Bazel

See CONTRIBUTING.md

Build status