Support sibling repository execution root layout.

Enable building and depending on targets in subpackages of //external.

Closes #10604.

1) Added --experimental_sibling_repository_layout starlark semantics flag
2) When enabled, the flag changes the execution root of external repository source artifacts (non-default/main repository) from <execroot cwd>/external/reponame to <execroot cwd>/../reponame. Therefore, this allows plantSymlinkForest to plant the "external" top level directory in the execution root, like any other top level source directory in the main repository.
3) The artifact roots (and therefore root relative path) of external repos' source artifacts are left unchanged. This enables RepositoryName#getRunfilesPath and RepositoryName#getSourceRoot to remain unchanged. Thus we only needed to thread StarlarkSemantics#experimentalAllowExternalDirectory from BazelRepositoryModule / ruleContext to callsites of RepositoryName#getExecPath(boolean allowExternalRepository).

This took a while because I had to revert some changes in order to make the other changes less intrusive.

Specifically, for external source artifacts, rosica's change set output_base/external as a source root, instead output_base. This causes all external source artifact's rootRelativePath to drop "external" as a prefix. By retaining the output_base source root, I was able to undo a lot of the intrusive changes.

Another caveat: this change currently clobbers output artifacts from external repositories and subpackages of //external in the same derived output root (bazel-bin/external). This will be a problem if external repository names conflicts with directory names in the top-level external directory. We'll probably have to draft up a design following this change.

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