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

Provide Starlark analogue to "rlocationpath" Make variable for rule authors to use #17259

Open
seh opened this issue Jan 19, 2023 · 7 comments
Open
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request

Comments

@seh
Copy link

seh commented Jan 19, 2023

Description of the feature request:

Per discussion in the "rules" channel of the "Bazel" Slack workspace, at present we have the rlocationpath "Make" variable available for use in target definitions, but we have no analogous Starlark function available to rule authors. It would be helpful to provide either a Starlark function that accepts a File or add a method to File that returns the equivalent string value as the rlocationpath "Make" variable, such that one could feed that value into a runfiles library's Rlocation function to find a particular runfile.

What underlying problem are you trying to solve with this feature?

While writing a rule that externalizes command-line flags or arguments supplied to an action created by ctx.actions.run or ctx.actions.run_shell, I'd like to supply values that nominate runfiles, such that the program that runs within that action can use a runfiles library to project those command-line flag values to the proper paths, allowing it to read the nominated files.

Which operating system are you running Bazel on?

macOS 13.1

What is the output of bazel info release?

release 6.0.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?

I have searched the Web extensively looking for advice on how to use the nascent runfiles libraries. @fmeum's "Runfiles and where to find them" video on YouTube helps understand how to consume these paths. Not addressed commonly, though, is how one creates these paths.

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

@fmeum mentioned his runfile_path Starlark function in the bazelbuild/rules_fuzzing repository as a potential implementation that emulates rlocationpath well enough.

@fmeum
Copy link
Collaborator

fmeum commented Jan 19, 2023

@c-parsons I remember this being blocked on the restriction that Starlark struct field implementation functions can't access the StarlarkThread. Do you know whether that restriction could be lifted to access the workspace name in File?

@c-parsons
Copy link
Contributor

@comius @brandjon

@sgowroji sgowroji added type: feature request untriaged team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols labels Jan 19, 2023
@fmeum
Copy link
Collaborator

fmeum commented Jan 20, 2023

@seh Isn't #17279 a fix for a different issue?

@brandjon brandjon added team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols labels Jan 20, 2023
@comius comius added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels Feb 14, 2023
@comius
Copy link
Contributor

comius commented Feb 14, 2023

I remember this being blocked on the restriction that Starlark struct field implementation functions can't access the StarlarkThread.

I think lifting this restriction would introduce a bit more magic to Starlark, so I'm not happy about it.

This could be done instead by a helper function.

What and where to introduce should be discussed on this ticked or even better in a design doc.

Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 20, 2024
@seh
Copy link
Author

seh commented Apr 20, 2024

This issue still describes an unmet need.

@fmeum
Copy link
Collaborator

fmeum commented Apr 20, 2024

This will be very simple to do once WORKSPACE is gone, because then it can just be field rather than a method on File.

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request
Projects
None yet
Development

No branches or pull requests

6 participants