Skip to content

feat(manifest): bare OS-alias sugar for [target.*] conditional tables (v0.0.80)#192

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/target-bare-alias
Jun 30, 2026
Merged

feat(manifest): bare OS-alias sugar for [target.*] conditional tables (v0.0.80)#192
Sunrisepeak merged 1 commit into
mainfrom
feat/target-bare-alias

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

What

Makes the common platform-conditional case concise. [target.linux.dependencies] / [target.windows.build] now work as sugar for [target.'cfg(linux)'...] — dropping the cfg(...) wrapper and its TOML-mandated quotes.

# before
[target.'cfg(windows)'.dependencies.compat]
openblas = "0.3.33"
# after
[target.windows.dependencies.compat]
openblas = "0.3.33"

Why it's unambiguous

A mcpp triple is always <arch>-<os>[-<env>]; the bare aliases windows/linux/macos/unix are never valid triples, so [target.linux] can only mean cfg(linux) — no collision with the exact-triple namespace ([target.x86_64-linux-musl]). A small, deliberate divergence from Cargo (which always requires cfg()/triple), justified by removing quote-noise from the 90% case.

Implementation

The parser already routes build/dependencies for every [target.<key>] into a ConditionalConfig{predicate=<key>}, so the only gap was evaluation. One branch in cfgpred::matches() evaluates a bare alias as the cfg bareword. Evaluation stays target-resolved (identical to cfg()); cfg(...) and exact triples unchanged → backward-compatible. toolchain/linkage remain exact-triple only (documented boundary).

Files

  • src/build/prepare.cppmcfgpred::matches() bare-alias branch.
  • tests/e2e/91_target_bare_alias.sh — bare alias works and equals cfg() per-OS (parity), host-aware (validates on linux/macOS/windows).
  • docs/05-mcpp-toml.md (+zh) — new §2.7.1 documenting all three [target.*] forms (the L1 conditional config was previously undocumented in the user guide).
  • .agents/docs/2026-06-30-target-bare-alias-sugar-design.md; version → 0.0.80.

Verified locally (0.0.80)

91_target_bare_alias passes; 85 (cfg flags) + 86 (cfg deps) regress clean; a macOS-gated bogus dep is correctly skipped on a Linux host via the bare alias.

🤖 Generated with Claude Code

… (v0.0.80)

[target.linux.dependencies] / [target.windows.build] now work as concise sugar
for [target.'cfg(linux)'...] — dropping the cfg() wrapper and its mandatory TOML
quotes for the common single-OS case. The bare aliases windows/linux/macos/unix
are never valid triples, so there's no ambiguity with the exact-triple namespace.

One evaluator branch in cfgpred::matches() (the parser already routes deps/build
for any [target.<key>] into conditionalConfigs); evaluation stays target-resolved,
identical to cfg(). Backward-compatible: cfg(...) and exact triples unchanged.
toolchain/linkage remain exact-triple only (documented).

- src/build/prepare.cppm: cfgpred::matches() bare-alias branch
- tests/e2e/91_target_bare_alias.sh: bare alias works + parity with cfg(), host-aware
- docs/05-mcpp-toml.md (+zh): new §2.7.1 documenting all three [target.*] forms
  (the L1 conditional config was previously undocumented in the user guide)
- design doc; version -> 0.0.80
@Sunrisepeak Sunrisepeak merged commit ec3b05f into main Jun 30, 2026
5 checks passed
@Sunrisepeak Sunrisepeak deleted the feat/target-bare-alias branch June 30, 2026 04:22
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