Skip to main content

Module condition

Module condition 

Source
Expand description

Typed model for cfg(...) target-condition expressions.

Cabin manifests can declare target-specific dependency tables, e.g.

[target.'cfg(os = "linux")'.dependencies]
epoll = "^1"

The condition string between the parentheses is parsed into a Condition AST and evaluated against a TargetPlatform describing the current evaluation context (the host build platform in this step). Parsing and evaluation are pure, deterministic, and side-effect-free.

Supported keys are intentionally narrow — os, arch, family, env, abi, target — and listed by the ConditionKey enum. Any other key is rejected at parse time so manifests do not silently rely on a future detection layer.

Public syntax is preserved as the canonical inner-expression string when round-tripped (see the Display impl on Condition); the manifest layer wraps it in cfg(...) and the metadata layer emits the bare inner form so JSON / on-disk shapes stay compact.

Structs§

TargetPlatform
Evaluation context for Condition::evaluate. Each field is a stable, normalized lowercase string. Unknown values flow through as the literal unknown, which is matchable in cfg(...) expressions.

Enums§

Condition
Typed AST for a cfg(...) target condition.
ConditionKey
Recognized target-condition keys. Anything else is rejected at parse time.
ConditionParseError
Errors produced while parsing a cfg(...) expression.