Add py2-bin functionality, and experimental flag to gate it

IMPORTANT: This flag is not intended to be supported long term, or to be turned on by default in Bazel.

This adds --experimental_create_py2_bin_symlink. When enabled, a <prefix>-py2-bin symlink will be created that mirrors the usual <prefix>-bin symlink, except that it points to a corresponding PY2 output root. When <prefix>-bin is already PY2 (e.g. --python_version=PY2, or if --incompatible_py3_is_default is not turned on, or --use_top_level_targets_for_symlinks is enabled and the top-level target is PY2), the two symlinks have the same destination.

BUILD files:
- Add dependencies on Python rules, since -py2-bin is naturally Python-specific.

BuildRequestOptions:
- Add the flag, clarify unrelated doc.

ExecutionTool:
- Add helper to obtain config from options using the executor. Turns out we have a myriad of ways to get configurations, at different levels of abstraction over the configuration machinery and with different levels of skyframe entanglement. Since we're doing a transition to get the new config, we don't have a BuildConfigurationValue.Key handy and instead have to use a different API. Pass along this helper as a callback to the symlink utils class.

OutputDirectoryLinksUtils:
- Add ConfigGroup, a value class to hold a single config for which we want to generate symlinks, along with its derived configs (here, the py2 config). This encapsulates the (minimal) Python-specific logic.
- Add Py2BinSymlink.

ConvenienceSymlinkTest:
- Test that the flag controls availability of the symlink, that it may or may not point to the same place as -bin, and that even when -bin can't be created because you're building both PY2 and PY3 targets, you can still use -py2-bin. We implement this using a mock Python rule that uses the real Python transition (including its baggage of requiring a dummy default_python_version attr).

ConfigurationResolver:
- Fix typo that briefly confused me.

Note that this machinery can be used to enable other symlinks that point to other -bin-like configs in the future -- not that we necessarily want to do that.

RELNOTES: None
PiperOrigin-RevId: 282410753
4 files changed
tree: c6d8b436cc406c1ecb991660d1a4051f1cbe12d0
  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