Skip to content

feat(sprout): generator variants - #105

Merged
azenla merged 2 commits into
mainfrom
azenla/feat/generator-variants
Oct 3, 2026
Merged

azenla merged 2 commits into
mainfrom
azenla/feat/generator-variants

Conversation

@azenla

@azenla azenla commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

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 own values. The entry name gets the choice names appended.

[generators.linux.bls]
entry.title = "$title ($console-title$mode-title)"
entry.actions = ["boot-linux"]

[generators.linux.variants]
console = [
  { name = "serial", values = { console-options = "console=ttyS0", console-title = "serial" } },
  { name = "graphics", values = { console-options = "", console-title = "graphics" } },
]
mode = [
  { name = "normal", values = { mode-options = "", mode-title = "" } },
  { name = "debug", values = { mode-options = "loglevel=7", mode-title = ", debug" } },
]

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

exclude removes 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.

[generators.linux]
exclude = [
  { chainload = "*-rescue-*" },
  { console = "graphics", mode = "debug" },
]

Related fixes

  • Entry matching for default-entry and 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.
  • The BLS generator has a new pin-names option, defaulting to true, which is the current behavior. A second BLS generator reading the same directory as autoconfigure used to produce entries with identical names. Setting pin-names = false prefixes 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>-*.
  • Prefixing entry names with the generator name moved from main.rs into generators::generate, so variants are built on the final names.

Testing

  • New unit tests in edera-sprout-parsing for glob matching, exclude rules and variant combinations.
  • cargo clippy -D warnings and cargo fmt --check are clean.

@azenla
azenla merged commit 96b6c6f into main Oct 3, 2026
12 checks passed
@azenla
azenla deleted the azenla/feat/generator-variants branch October 3, 2026 22:16
azenla added 2 commits October 3, 2026 15:30
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.
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.

1 participant