-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds an `attrs` param to the `macro()` callable, allowing users to specify an attribute schema for symbolic macros. As for rules, the `name` attribute is implied and should not be included in `attrs`, while certain other names are reserved and can never be defined on macros. Macros support default values and implicit defaults, but not computed defaults or late-bound defaults. StarlarkRuleClassFunctions.java - Add attr schema validation to `macro()`. - Factor instantiation logic from `MacroFunction#call()` to `MacroClass#instantiateAndAddMacro()`. - Replace ad hoc `name` attr validation with standard RuleClass#NAME_ATTRIBUTE logic. BuildType.java - In `copyAndLiftStarlarkValue`, generalize `ruleClass` param to apply to macros as well, and update stringification in `AttributeConversionContext` accordingly. MacroClass.java - Add significant new logic to instantiate a macro by processing and validating its attribute values. BazelEvaluationTestCase.java - Add ability to inject config fragments into the Starlark environment. Used by one new test case that can't take advantage of `BuildViewTestCase`'s existing fragment setup. New test cases are added to StarlarkRuleClassFunctionsTest.java and SymbolicMacroTest.java, with the loose rationale that the former is for cases that don't require an implementation function to run and the latter is for everything else. But it may be more sensible to just move all the symbolic macro tests to the latter file in the future. Work toward #19922. PiperOrigin-RevId: 626042528 Change-Id: Ie1c09cfdf2ca2168467035b2fa0ccd75cbf68dfd
- Loading branch information
1 parent
0f93a6b
commit 6062db1
Showing
12 changed files
with
719 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.