Skip to content

feat(features): per-feature per-glob flags + per-OS features semantics (#253) — 0.0.101#255

Merged
Sunrisepeak merged 2 commits into
mainfrom
feat/issue-253-feature-flags-per-os-features
Jul 20, 2026
Merged

feat(features): per-feature per-glob flags + per-OS features semantics (#253) — 0.0.101#255
Sunrisepeak merged 2 commits into
mainfrom
feat/issue-253-feature-flags-per-os-features

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Closes #253. Design doc (with implementation log): .agents/docs/2026-07-20-issue-253-feature-flags-and-per-os-features-design.md.

What

1. features.<name>.flags — per-feature per-glob compile flags (both grammars)

  • Same entry grammar as [build].flags (glob required + cflags/cxxflags/asmflags/defines), shared parser per grammar: xpkg parse_glob_flags_array, TOML parse_glob_flags_value — one data model, two grammars.
  • Activation folds the active features' entries into the one buildConfig.globFlags funnel (prepare.cppm apply()), after base entries, features in name order → "last flag wins" lets a feature rule override a broader base rule. Scanner matching, per-TU flag landing, zero-hit warning and fingerprint all consume the same vector unchanged.
  • Fold sits outside the includeDevDeps gate (0.0.94 dual-path invariant: mcpp build and mcpp test agree).
  • Private per-TU, non-propagating — contrast feature defines (interface switches that propagate along Public/Interface edges). Locked by e2e.
  • Feature off → the rule does not exist → compat.opencv's mlas dead-glob warnings disappear. Feature on with a dead glob → warning still fires, now naming the owning feature (features.<f>.flags glob '...' matched no source file).
  • TOML #227 closed-grammar AOT allowlist gains a features.*.flags wildcard segment, so both the inline array and [[features.<name>.flags]] spellings work.

2. per-OS features — semantics locked, no new mechanism

  • The mcpp.<os> textual-splice additive overlay already covers features; this PR locks the semantics (per-subkey APPEND — neutral body first, OS body after; OS-only feature registration; non-host sections invisible) with unit tests (both legs via osOverride) + e2e, and documents the common/delta authoring shape opencv dnn needs.

3. Fingerprint hardening

  • Dependency globFlags were never in the per-package fingerprint (previously held by descriptor-frozen-per-version + feature toggles always touching cflags). Feature folding makes the vector build-variant → canonical_package_build_metadata now serializes it like the root side. featureOrigin is diagnostic-only, not fingerprinted.

Split out: the per-OS splice keys on the host OS constant while target_cfg uses the resolved target — cross builds pick the wrong per-OS payload. Filed as #254 (native builds unaffected; not needed for #253's unblock).

Tests

  • Unit: Manifest.FeatureFlagsTomlTableForm/FeatureFlagsTomlErrors, SynthesizeFromXpkgLua.FeatureFlagsParse/PerOsFeaturesAdditiveMerge — 35/35 suites green locally.
  • e2e 146: four quadrants (off/on × build/test), no dead-glob warning when off, feature-named warning for an active dead glob, per-TU scoping (no leak to sibling TU), dep half asserting defines propagate while flags do not.
  • e2e 147: per-OS features end-to-end via local index descriptor — host section's per-OS feature source + its per-OS feature flag applied; poisoned non-host section (#error TU) must stay invisible; feature-off leaves all gated sources out.
  • Full local e2e: 135 passed / 4 failed — 22/54/62 are the known environmental failures; 09 failed in-suite (artifact of mid-run version bump touching the repo) and passes in isolation.

Version

0.0.100 → 0.0.101 (mcpp.toml + fingerprint.cppm), CHANGELOG entry included.

#253)

Two feature-model gaps surfaced by compat.opencv's 3-platform dnn work:

- features.<name>.flags — per-feature per-glob compile flags, one entry
  grammar with [build].flags (shared parser in both grammars: xpkg
  parse_glob_flags_array, TOML parse_glob_flags_value). Active features
  fold their entries into the ONE buildConfig.globFlags funnel (after
  base entries, features in name order, "last flag wins"), so scanner
  matching, per-TU flag landing, the zero-hit warning and fingerprint
  serialization all consume it unchanged. Fold sits OUTSIDE the
  includeDevDeps gate (0.0.94 dual-path invariant). Private per-TU,
  non-propagating (contrast feature defines = interface switches).
  Feature-off builds no longer carry the rule at all — opencv's mlas
  dead-glob warnings disappear; an active feature's dead glob still
  warns, now naming the owning feature. TOML AOT allowlist gains a
  features.*.flags wildcard segment (aot_path_matches) so both the
  inline and [[features.X.flags]] spellings pass the #227 closed guard.

- per-OS features — the mcpp.<os> textual-splice additive overlay
  already covers the features key; semantics (per-subkey APPEND, base
  first / OS body after, OS-only feature registration) are now locked by
  unit tests (per-leg via osOverride) + e2e and documented. Together
  with per-feature flags this gives opencv dnn its common/delta shape
  (neutral common payload, per-OS mlas-x86/NEON deltas + their flags).

Also: dependency globFlags were never serialized into the per-package
fingerprint (held only by descriptor-frozen-per-version + feature
toggles always touching cflags); feature folding makes the vector
build-variant, so canonical_package_build_metadata now serializes it
like the root side. featureOrigin is diagnostic-only, not fingerprinted.

Tests: unit (TOML/xpkg parse, closed-grammar errors, per-OS additive
merge both legs), e2e 146 (four quadrants, dead-glob warning
elimination + feature-scoped naming, private non-propagation vs define
propagation), e2e 147 (per-OS features end-to-end, poisoned non-host
section must stay invisible).

Host-vs-target splice-axis defect found during this work is split out
as #254. Design: .agents/docs/2026-07-20-issue-253-feature-flags-and-
per-os-features-design.md. Version 0.0.100 -> 0.0.101.
…s has no path->string implicit conversion (wstring value_type)
@Sunrisepeak
Sunrisepeak merged commit af25d18 into main Jul 20, 2026
7 checks passed
@Sunrisepeak
Sunrisepeak deleted the feat/issue-253-feature-flags-per-os-features branch July 20, 2026 10:28
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.

xpkg: per-feature flags + per-OS features (finish opencv dnn off-linux, silence dead-glob warnings)

1 participant