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

alias targets should expose FilesToRunProvider if actual has one #17749

Closed
illicitonion opened this issue Mar 13, 2023 · 1 comment
Closed

alias targets should expose FilesToRunProvider if actual has one #17749

illicitonion opened this issue Mar 13, 2023 · 1 comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@illicitonion
Copy link
Contributor

Description of the bug:

I have code which runs a cquery to gets the executable of a FilesToRunProvider:

bazel cquery --output=starlark --starlark:expr="providers(target).get(\"FilesToRunProvider\").executable.path"

This doesn't work for alias targets which point to binary targets. It probably should.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD file:

py_binary(
    name = "bin",
    srcs = ["bin.py"],
)

alias(
    name = "alias",
    actual = ":bin",
)

Run: bazel cquery --output=starlark --starlark:expr="providers(target).get(\"FilesToRunProvider\").executable.path" :alias

expect to get an output path. Instead, get an error because providers(target).get("FilesToRunProvider") is None.

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

release 6.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@fmeum
Copy link
Collaborator

fmeum commented Mar 13, 2023

Seems to be a much more general issue:

$ bazel cquery --output=starlark --starlark:expr="providers(target)" :alias
None

@sgowroji sgowroji added type: bug team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged labels Mar 13, 2023
@gregestren gregestren added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Mar 13, 2023
ShreeM01 pushed a commit to ShreeM01/bazel that referenced this issue Mar 15, 2023
When applied to an `alias` target, the `providers` function of `cquery`'s `--output=starlark` mode now returns the providers of the aliased target rather than `None`.

This is achieved by moving `getProvidersDict` from `AbstractConfiguredTarget` up to `ConfiguredTarget`.

Fixes bazelbuild#17749

Closes bazelbuild#17753.

PiperOrigin-RevId: 516707744
Change-Id: I840588d605e3a64b968a019cf4bf43b56d18f4f5
keertk added a commit that referenced this issue Mar 20, 2023
* Add support for alias targets to cquery's `providers`

When applied to an `alias` target, the `providers` function of `cquery`'s `--output=starlark` mode now returns the providers of the aliased target rather than `None`.

This is achieved by moving `getProvidersDict` from `AbstractConfiguredTarget` up to `ConfiguredTarget`.

Fixes #17749

Closes #17753.

PiperOrigin-RevId: 516707744
Change-Id: I840588d605e3a64b968a019cf4bf43b56d18f4f5

* Remove extra code

---------

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Co-authored-by: keertk <keerthanakumar@google.com>
illicitonion added a commit to illicitonion/target-determinator that referenced this issue May 16, 2023
illicitonion added a commit to illicitonion/target-determinator that referenced this issue May 17, 2023
illicitonion added a commit to bazel-contrib/target-determinator that referenced this issue May 17, 2023
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
When applied to an `alias` target, the `providers` function of `cquery`'s `--output=starlark` mode now returns the providers of the aliased target rather than `None`.

This is achieved by moving `getProvidersDict` from `AbstractConfiguredTarget` up to `ConfiguredTarget`.

Fixes bazelbuild#17749

Closes bazelbuild#17753.

PiperOrigin-RevId: 516707744
Change-Id: I840588d605e3a64b968a019cf4bf43b56d18f4f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants