commit | 9ad0a7367d2782426b6f39352b6e05e77e9b19be | [log] [tgz] |
---|---|---|
author | gregce <gregce@google.com> | Mon May 02 10:34:20 2022 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Mon May 02 10:43:17 2022 -0700 |
tree | 16d0ad8db2a3d6ca5bc6396507d5fea3731882b0 | |
parent | ecc293d049688e7a23d2f322b364d582bc9d4de4 [diff] |
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
{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.
Follow our tutorials:
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.
See CONTRIBUTING.md