Eliminate package lookup from ASTFileLookupFunction

BzlLoadFunction does a package lookup to confirm that the requested bzl label does indeed have a corresponding package. However, ASTFileLookupFunction repeats this lookup so that it can obtain the Root for the actual file retrieval. This is an unnecessary Skyframe dep, and is replaced by incorporating the Root into the ast key.

There may be some observable changes, e.g. regarding the error messages for edge cases like a prelude file that crosses package boundaries. The bigger changes will be when we load the prelude using BzlLoadFunction.

This resolves a TODO left behind in the wake of --incompatible_disallow_load_labels_to_cross_package_boundaries. It follows in the footsteps of unknown commit (parts of which were subsequently done in unknown commit).

PackageFunction changes:
- Auto-format file, add "static"
- Inline away preludeLabel field
- Factor off prelude lookup into a helper. This will go away when prelude loading is merged into bzl loading. In the meantime, this logic gets more complicated due to the new need to do package lookup for the prelude file (since it won't be done inside ASTFileLookupFunction).

Other notes:
- Eliminate a redundant test in ASTFileLookupFunctionTest, and rename some scratch files (the test cases appear to believe ASTFileLookupFunction can be used to load BUILD files)

Work toward #11437 and toward flat Starlark environments.

RELNOTES: None
PiperOrigin-RevId: 325459040
7 files changed
tree: 6aabcde59da425cce3a4e2544077eb3e832f5231
  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