Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible_disallow_ctx_resolve_tools #22249

Open
tjgq opened this issue May 6, 2024 · 0 comments
Open

incompatible_disallow_ctx_resolve_tools #22249

tjgq opened this issue May 6, 2024 · 0 comments
Labels
incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green

Comments

@tjgq
Copy link
Contributor

tjgq commented May 6, 2024

This flag disallows uses of the ctx.resolve_tools API, which is awkward to use and redundant with other existing APIs.

To migrate, replace this pattern:

tool_inputs, input_manifests = ctx.resolve_tools(tools = [ctx.attr._my_tool])
...
ctx.actions.run(
  inputs = tool_inputs + ...,
  input_manifests = input_manifests,
  ...
)

with one of

ctx.actions.run(executable = ctx.executable._my_tool, ...)

or

ctx.actions.run(tools = [ctx.executable._my_tool], ...)

When using ctx.actions.run_shell, the latter form is required. Otherwise, when using ctx.actions.run, prefer the former (i.e., if the tool in question is the executable for the action, there's no need to also pass it under tools).

Note that ctx.executable._my_tool refers solely to the executable file, but passing it to the executable or tools argument automatically includes its associated runfiles in the action inputs, as long as the tool is a direct dependency of the target calling ctx.actions.run/ctx.actions.run_shell. If you want to pass the tool around (e.g., in a returned provider) for other targets to use, you must obtain a FilesToRunProvider via ctx.attr._my_tool[DefaultInfo].files_to_run, and pass it around instead.

@tjgq tjgq added incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change migration-ready Incompatible flag is ready for migration with Bazel rolling releases or Bazel@last_green
Projects
None yet
Development

No branches or pull requests

1 participant