Extend Android path stripping testing by integrating aquery output.

## Description
aquery prints command lines by calling CommandAction.getArguments(): https://github.com/bazelbuild/bazel/blob/ee9727df980f268bfb2b05637d199d55963fb6d8/src/main/java/com/google/devtools/build/lib/query2/aquery/ActionGraphTextOutputFormatterCallback.java#L262.

Java commands (like JavaCompileAction) pass this to CustomCommandLine, which for path stripped actions is a PathStrippingCustomCommandLine that knows to apply path stripping appropriately. For these actions this change is a noop.

Starlark action construction (including Android actions) is more complicated: the StarlarkCustomCommandLine equivalent is set before path stripping can be known. StarlarkCustomCommandLine reads Starlark code before the action is instantiated and its full inputs and outputs are known. We need that info to set path stripping.

So when Bazel requests a Starlark action's command, it passes the stripPath bit as a parameter to StarlarkCustomCommandLine's arguments() call (see this cl's change to SpawnAction - that calls CommandLines.allArguments() which calls StarlarkCustomCommandLine.arguments()).

This change ensures that call properly passes the bit.

This lets config_stripped_outputs_test use aquery to identify path stripping in more actions, so more tests are added here.

## Wider API consequences
This change affects *any* caller to SpawnAction.getArguments(). This includes callers like ActionExecutedEvent: https://github.com/bazelbuild/bazel/blob/bc2f0519a4e6f0ac3ea42ff50da2c9919c5b6c0e/src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java#L250. It's unclear if we want this caller to strip paths.

It also affects some action key computations, like https://github.com/bazelbuild/bazel/blob/cb01bde9369f8197cb54c34b14aa41f0dcc903cf/src/main/java/com/google/devtools/build/lib/rules/cpp/LtoBackendAction.java#L225. This seems safe according to the contract for action keys: https://github.com/bazelbuild/bazel/blob/e4c1c434d49062449c7a83dd753fe01923766b1d/src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java#L64-L84. Note that the affected callers are noops since those actions don't use path stripping.

There are also a few debugging callers, similar in spirit to aquery.

All this is more complicated than I'd prefer (i.e. the different logic for constructing Java vs. Starlark actions). I'd consider better API consistency down the line but for now I think the current balance is manageable.

https://github.com/bazelbuild/bazel/issues/6526

PiperOrigin-RevId: 445970260
3 files changed
tree: 16d0ad8db2a3d6ca5bc6396507d5fea3731882b0
  1. .bazelci/
  2. .github/
  3. examples/
  4. scripts/
  5. site/
  6. src/
  7. third_party/
  8. tools/
  9. .bazelrc
  10. .gitattributes
  11. .gitignore
  12. AUTHORS
  13. BUILD
  14. CHANGELOG.md
  15. CODE_OF_CONDUCT.md
  16. CODEBASE.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. MODULE.bazel
  27. README.md
  28. SECURITY.md
  29. WORKSPACE
  30. 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