Repository navigation
feat(sprout): generator variants - #105
Merged
Merged
Conversation
Generators can now declare variant axes. Every generated entry is multiplied by each combination of choices, one per axis. A choice sets the axis name to the choice name and inserts its own values, and the entry name is suffixed with the choice names. Generators can also declare exclude rules, which remove generated entries whose values match every glob pattern in a rule. This covers unwanted variant combinations and entries like BLS rescue kernels. Entry matching for default-entry and the bootloader interface now accepts `*` anywhere in the pattern instead of only at the end, so generated entry names can be matched regardless of the kernel version in the middle of the name. The BLS generator gains a pin-names option (default true, the existing behavior). Two BLS generators reading the same directory previously produced entries with identical names; disabling pin-names prefixes them with the generator name instead. Sprout now warns when more than one entry has the same name.
Pinned BLS entry names match the BLS entry ids, but variants still append their choice names, so those entries need a pattern like <id>-* to be selected.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds variants and exclude rules to generators, so a family of near-identical entries can be declared once instead of copied per combination.
Variants
A generator can declare variant axes. Each axis is a list of choices, and every entry the generator produces is multiplied by every combination of choices, one per axis. A choice sets
$<axis>to its name and inserts its ownvalues. The entry name gets the choice names appended.This works with any generator kind (
bls,list,matrix). Axes are applied in alphabetical order, and choices in the order they are declared. An axis with no choices, or with two choices of the same name, is a configuration error.Exclude rules
excluderemoves generated entries after variants are applied. Each rule maps value names to glob patterns. An entry is dropped when every key in any one rule matches.Related fixes
default-entryand the bootloader interface now supports*anywhere in the pattern, not just at the end. When several entries match, the first one in menu order is still used.pin-namesoption, defaulting totrue, which is the current behavior. A second BLS generator reading the same directory as autoconfigure used to produce entries with identical names. Settingpin-names = falseprefixes them with the generator name instead. Sprout now logs a warning when two entries share a name. Pinned names still get variant suffixes, so a pinned entry with variants is selected with a pattern like<id>-*.main.rsintogenerators::generate, so variants are built on the final names.Testing
edera-sprout-parsingfor glob matching, exclude rules and variant combinations.cargo clippy -D warningsandcargo fmt --checkare clean.