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

Add support for expansions in expand_template #525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

keith
Copy link
Member

@keith keith commented Jun 24, 2024

This is useful for providing paths from data, and custom variables from toolchains

@keith keith force-pushed the ks/add-support-for-data-in-expand_template branch from 44814b2 to 1b19c61 Compare June 24, 2024 18:17
This can be useful for encoding the paths to things in your expansions
@keith keith force-pushed the ks/add-support-for-data-in-expand_template branch from 1b19c61 to d5ae39f Compare June 24, 2024 18:30
@keith keith changed the title Add support for data in expand_template Add support for expansions in expand_template Jun 24, 2024
@@ -16,10 +16,21 @@
"""

def _expand_template_impl(ctx):
expanded_substitutions = {}
for key, value in ctx.attr.substitutions.items():
expanded_substitutions[key] = ctx.expand_make_variables(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.expand_make_variable is marked as "Deprecated" in Bazel documentation. People before me marked it that way and I think we shouldn't introduce new uses.

Please remove it's use.

I believe it's implementable in Starlark, and skylib would be a nice location for such an implementation. (And we might already have one implementation in the C++ rules in builtins).

The rest of the PR seems fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relevant convo https://groups.google.com/g/bazel-discuss/c/WEnG-WocaTc

so you're saying we should make a new function to do the same thing in skylib and use that here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I bumped bazelbuild/bazel#5859 to P3.

And I noticed also #486 which might already be doing that. Would you like to help in review?

There might be other PRs, I haven't gone through all of them yet.

tests/expand_template/BUILD Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants