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

Allow declaring new private attributes when inheriting in a symbolic macro #25055

Open
joca-bt opened this issue Jan 24, 2025 · 0 comments
Open
Labels
team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: feature request untriaged

Comments

@joca-bt
Copy link

joca-bt commented Jan 24, 2025

Description of the feature request:

When defining a symbolic macro based on an existing rule or macro and using attribute inheritance, it's not possible to add a new attribute not present in the rule or macro being inherited.

Adding new attributes may be useful, particularly if they're private. For example, let's say I'm wrapping java_test to use my own test runner. I imagine the ideal way to provide my test runner to the macro is via a private atribute, similary to how we would do it if we were defining a rule:

my_test_wrapper = macro(
    inherit_attrs = java_test,
    attrs = {
        ... // block some attributes via None
        "_test_runner": attr.label(
            default = "//test-runner",
            allow_single_file = True,
        ),
    },
    ...
)

Error: no such attribute '_test_runner' in 'java_test' rule (did you mean 'use_testrunner'?)

While I can understand adding public attributes could not be desired, I think allowing private attributes can be very useful.

Which category does this issue belong to?

Rules API

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

Creating more powerful macros.

Which operating system are you running Bazel on?

WSL

What is the output of bazel info release?

release 8.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 HEAD ?


Have you found anything relevant by searching the web?

No response

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

No response

@github-actions github-actions bot added the team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts label Jan 24, 2025
@joca-bt joca-bt changed the title Allow declaring new attributes when inheriting in a symbolic macro Allow declaring new private attributes when inheriting in a symbolic macro Jan 24, 2025
@comius comius added team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob and removed team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

5 participants