Documentation
¶
Index ¶
- Variables
- func Load(ctx context.Context, entry string, options LoadOptions) (*Project, Diagnostics, error)
- func ParseDocument(source Source) (*Document, Diagnostics)
- func ParseExpr(text string, span SourceSpan) (Expr, Diagnostics)
- func ParseValue(kind ValueType, raw string) (Value, Diagnostic)
- func WriteConfig(state ConfigState) (string, error)
- func WriteConfigWithOptions(state ConfigState, options WriteConfigOptions) (string, error)
- func WriteKconfig(project *Project) (string, error)
- type Change
- type ChangeStatus
- type ConditionalValue
- type ConfigState
- type Constraints
- type Diagnostic
- type Diagnostics
- type Document
- type Entry
- type EntryKind
- type EntrySchema
- type Error
- type ErrorCode
- type Expr
- type FSLoader
- type FrontendInput
- type FrontendTree
- type LoadOptions
- type MacroFunc
- type MacroOptions
- type Node
- type NodeKind
- type Project
- func (p *Project) Apply(state ConfigState, patch FrontendInput) Resolution
- func (p *Project) OpenScreen(state ConfigState, id string, options RenderOptions) ScreenResult
- func (p *Project) Render(state ConfigState, options RenderOptions) FrontendTree
- func (p *Project) Resolve(input FrontendInput) Resolution
- func (p *Project) Schema() Schema
- func (p *Project) Validate(state ConfigState, symbolID string, candidate any) ValidationResult
- type Property
- type RangeRule
- type Relation
- type RenderOptions
- type Resolution
- type Schema
- type Screen
- type ScreenRef
- type ScreenResult
- type ScreenSchema
- type Severity
- type Source
- type SourceLoader
- type SourceSpan
- type StateReason
- type SymbolLookup
- type SymbolSchema
- type Token
- type TokenKind
- type TriState
- type ValidationResult
- type Value
- type ValueOption
- type ValueOrigin
- type ValueType
- type WriteConfigOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidDirective error = errorCodeSentinel{ErrorCodeInvalidDirective} ErrInvalidBlock error = errorCodeSentinel{ErrorCodeInvalidBlock} ErrUnsupportedDirective error = errorCodeSentinel{ErrorCodeUnsupportedDirective} ErrInvalidExpression error = errorCodeSentinel{ErrorCodeInvalidExpression} ErrInvalidRange error = errorCodeSentinel{ErrorCodeInvalidRange} ErrDefaultTypeMismatch error = errorCodeSentinel{ErrorCodeDefaultTypeMismatch} ErrInvalidValue error = errorCodeSentinel{ErrorCodeInvalidValue} ErrInvalidJSONValue error = errorCodeSentinel{ErrorCodeInvalidJSONValue} ErrUnknownValueType error = errorCodeSentinel{ErrorCodeUnknownValueType} ErrRootPath error = errorCodeSentinel{ErrorCodeRootPath} ErrIncludeEscape error = errorCodeSentinel{ErrorCodeIncludeEscape} ErrIncludeCycle error = errorCodeSentinel{ErrorCodeIncludeCycle} ErrSourceRead error = errorCodeSentinel{ErrorCodeSourceRead} ErrUnresolvedVariable error = errorCodeSentinel{ErrorCodeUnresolvedVariable} ErrShellMacro error = errorCodeSentinel{ErrorCodeShellMacro} ErrEnvironmentMacro error = errorCodeSentinel{ErrorCodeEnvironmentMacro} ErrPythonMacro error = errorCodeSentinel{ErrorCodePythonMacro} ErrCustomMacro error = errorCodeSentinel{ErrorCodeCustomMacro} ErrMacroExecution error = errorCodeSentinel{ErrorCodeMacroExecution} ErrMacroSyntax error = errorCodeSentinel{ErrorCodeMacroSyntax} ErrUnsupportedMacro error = errorCodeSentinel{ErrorCodeUnsupportedMacro} ErrIncompatibleSymbol error = errorCodeSentinel{ErrorCodeIncompatibleSymbol} ErrUndeclaredSymbol error = errorCodeSentinel{ErrorCodeUndeclaredSymbol} ErrUninitializedProject error = errorCodeSentinel{ErrorCodeUninitializedProject} ErrUnknownSymbol error = errorCodeSentinel{ErrorCodeUnknownSymbol} ErrResolutionConvergence error = errorCodeSentinel{ErrorCodeResolutionConvergence} ErrInvalidState error = errorCodeSentinel{ErrorCodeInvalidState} ErrMissingRootDocument error = errorCodeSentinel{ErrorCodeMissingRootDocument} ErrUnsafeConfigOutput error = errorCodeSentinel{ErrorCodeUnsafeConfigOutput} )
The Err variables are stable error identities for errors.Is. Their matching ErrorCode is exposed on Error and Diagnostic for callers that serialize, switch on, or display the library's error taxonomy.
Functions ¶
func Load ¶
func Load(ctx context.Context, entry string, options LoadOptions) (*Project, Diagnostics, error)
Load reads entry and its included documents, validates their structure, and builds an immutable Project.
func ParseDocument ¶
func ParseDocument(source Source) (*Document, Diagnostics)
ParseDocument parses one Kconfig source document.
func ParseExpr ¶
func ParseExpr(text string, span SourceSpan) (Expr, Diagnostics)
ParseExpr parses an expression with Kconfig operator precedence.
func ParseValue ¶
func ParseValue(kind ValueType, raw string) (Value, Diagnostic)
ParseValue parses one Kconfig literal as the requested type.
func WriteConfig ¶
func WriteConfig(state ConfigState) (string, error)
WriteConfig emits a deterministic Linux .config file. Disabled bool and tristate symbols use Linux's conventional unset spelling. It uses restrictive output validation; use WriteConfigWithOptions only when every value and symbol declaration is trusted.
func WriteConfigWithOptions ¶ added in v1.2.0
func WriteConfigWithOptions(state ConfigState, options WriteConfigOptions) (string, error)
WriteConfigWithOptions emits a deterministic Linux .config file. Disabled bool and tristate symbols use Linux's conventional unset spelling. Its zero value options enable restrictive validation; callers must explicitly set TrustInput to bypass that validation.
func WriteKconfig ¶
WriteKconfig emits normalized definitions. It intentionally does not keep original whitespace or comments positioning; Project is semantic model data.
Types ¶
type Change ¶
type Change struct {
// Input is the unnormalized frontend scalar supplied by the caller.
Input any
// Status records whether resolution accepted, normalized, fell back from, or ignored Input.
Status ChangeStatus
// Previous is the initial scalar and Value is the resolved final scalar.
Previous, Value Value
// Reason explains fallback or ignored input when applicable.
Reason *StateReason
}
Change records the outcome of one submitted or normalized symbol value.
type ChangeStatus ¶
type ChangeStatus uint8
ChangeStatus reports how a submitted frontend value was handled during resolution.
const ( // ChangeAccepted means the direct frontend scalar remained valid. ChangeAccepted ChangeStatus = iota // ChangeNormalized means resolution supplied the final value without direct input. ChangeNormalized // ChangeFallback means direct input was replaced by an active default or constraint result. ChangeFallback // ChangeIgnored means the input referred to an unknown symbol. ChangeIgnored )
type ConditionalValue ¶
type ConditionalValue struct {
// Value holds a literal default in the declared symbol type.
Value Value
// Expr is used for symbol-valued defaults (for example, `default FOO`).
// Value is retained for literal defaults so callers do not need to reparse
// source text to render a default.
Expr Expr
// Raw preserves the normalized source spelling for canonical writing.
Raw string
// Condition controls whether this default can apply; nil means unconditional.
Condition Expr
// Span locates the default in its source document.
Span SourceSpan
}
ConditionalValue is a default value whose application may depend on an expression.
type ConfigState ¶
type ConfigState struct {
// contains filtered or unexported fields
}
ConfigState is an immutable-by-convention resolved value set tied to one Project.
func (ConfigState) Value ¶
func (s ConfigState) Value(symbolID string) Value
Value returns the current symbol value, or the declared zero value when the symbol is known but unset.
func (ConfigState) Values ¶
func (s ConfigState) Values() map[string]Value
Values returns a copy of the resolved symbol map so callers cannot mutate ConfigState internals.
type Constraints ¶
type Constraints struct {
// Type controls the frontend scalar type and validation rules.
Type ValueType
// Min and Max are active inclusive bounds when the symbol has a range.
Min, Max *Value
// AllowedValues enumerates toggles, tristates, or choice members where applicable.
AllowedValues []ValueOption
}
Constraints describes the current type, range, and selectable values of a node.
type Diagnostic ¶
type Diagnostic struct {
// Severity classifies the impact of the diagnostic.
Severity Severity
// Code is the stable machine-readable category. Use errors.Is with the
// matching Err variable when callers prefer Go's error matching protocol.
Code ErrorCode
// Message is a human-readable explanation that does not include source position.
Message string
// Span identifies the relevant source location when one is available.
Span SourceSpan
// Cause preserves an external underlying error, such as a SourceLoader read error.
Cause error
}
Diagnostic explains a load, semantic, or input issue.
func (Diagnostic) Error ¶ added in v1.1.0
func (d Diagnostic) Error() string
Error returns the diagnostic message for APIs that accept an individual error.
func (Diagnostic) Is ¶ added in v1.1.0
func (d Diagnostic) Is(target error) bool
Is reports whether target is the sentinel belonging to this diagnostic's Code.
func (Diagnostic) Unwrap ¶ added in v1.1.0
func (d Diagnostic) Unwrap() error
Unwrap returns the underlying external cause, when one exists.
type Diagnostics ¶
type Diagnostics []Diagnostic
Diagnostics is an ordered collection of diagnostics.
func (Diagnostics) Error ¶
func (d Diagnostics) Error() string
Error renders all diagnostics for use with error-returning APIs.
func (Diagnostics) HasErrors ¶
func (d Diagnostics) HasErrors() bool
HasErrors reports whether any error-level diagnostic is present.
type Document ¶
type Document struct {
// Title is the optional mainmenu title declared by the document.
Title string
// Root is the synthetic entry that owns the document's top-level entries.
Root *Entry
}
Document is one parsed Kconfig source file.
type Entry ¶
type Entry struct {
// ID is a stable, source-derived identity assigned during indexing.
ID string
// Kind determines which Kconfig construct this entry represents.
Kind EntryKind
// Name is the symbol name or include path, depending on Kind.
Name string
// IncludeKind preserves source/rsource/osource/orsource for include entries.
IncludeKind string
// Prompt is the human-readable text shown for this entry.
Prompt string
// PromptCondition controls whether Prompt is active.
PromptCondition Expr
// Type is the declared value type for configuration entries.
Type ValueType
// Condition is the expression attached to an if entry.
Condition Expr
// Selects and Implies define relationships initiated by this entry.
Selects []Relation
Implies []Relation
// Defaults and Ranges retain rules in source order.
Defaults []ConditionalValue
Ranges []RangeRule
// Depends affects configuration semantics, while Visible affects presentation only.
Depends []Expr
Visible []Expr
// Help is the normalized multi-line help body for this entry.
Help string
// OptionModules marks the symbol that controls tristate module availability.
OptionModules bool
// Optional permits a choice to have no selected member.
Optional bool
// Properties preserves source property order for canonical writing. The
// semantic fields above remain the efficient, typed representation.
Properties []Property
// Children are nested source entries in their original order.
Children []*Entry
// Span identifies the entry declaration in its source document.
Span SourceSpan
}
Entry is a source-ordered menu-tree node.
type EntryKind ¶
type EntryKind uint8
EntryKind identifies a Kconfig menu-tree entry.
const ( // EntryRoot is the synthetic document root and is never rendered directly. EntryRoot EntryKind = iota // EntryConfig declares a regular configuration symbol. EntryConfig // EntryMenuConfig declares a configuration symbol that also opens a screen. EntryMenuConfig // EntryMenu groups nested entries into a navigable screen. EntryMenu // EntryChoice restricts nested configuration symbols to one selected member. EntryChoice // EntryIf conditionally scopes its nested entries. EntryIf // EntryComment provides non-interactive display text. EntryComment // EntryInclude points to another source document loaded into this tree. EntryInclude )
type EntrySchema ¶
type EntrySchema struct {
// ID is a stable declaration/menu-entry identity, not a submitted-value key.
ID string
// SymbolID is the submitted-value key for configuration entries and empty otherwise.
SymbolID string
// ParentID is the static parent screen ID.
ParentID string
// Prompt is the source prompt visible to users when its conditions allow it.
Prompt string
// Kind identifies the Kconfig construct represented by this entry.
Kind EntryKind
// Type is the declared value type for configuration entries.
Type ValueType
// Source locates the declaration in its source document.
Source SourceSpan
// ScreenID is the child screen opened by this menu or menuconfig entry, if any.
ScreenID string
}
EntrySchema describes one source declaration in the static menu tree.
type Error ¶ added in v1.1.0
Error is a detailed library error with a stable Code and optional external Cause. Use errors.Is with the matching Err variable and errors.As to inspect an underlying filesystem, JSON, or caller-supplied error.
type ErrorCode ¶ added in v1.1.0
type ErrorCode string
ErrorCode is a stable, machine-readable category for a library failure. It identifies the reason and subsystem without replacing Error or Diagnostic messages, which retain the operation-specific detail intended for people.
const ( // ErrorCodeInvalidDirective identifies a malformed Kconfig directive or argument. ErrorCodeInvalidDirective ErrorCode = "invalid-directive" // ErrorCodeInvalidBlock identifies an invalid, mismatched, or unclosed Kconfig block. ErrorCodeInvalidBlock ErrorCode = "invalid-block" // ErrorCodeUnsupportedDirective identifies an unsupported Kconfig directive. ErrorCodeUnsupportedDirective ErrorCode = "unsupported-directive" // ErrorCodeInvalidExpression identifies malformed expression syntax, tokens, or literals. ErrorCodeInvalidExpression ErrorCode = "invalid-expression" // ErrorCodeInvalidRange identifies a malformed or invalid Kconfig range. ErrorCodeInvalidRange ErrorCode = "invalid-range" // ErrorCodeDefaultTypeMismatch identifies a default whose type conflicts with its symbol. ErrorCodeDefaultTypeMismatch ErrorCode = "default-type-mismatch" // ErrorCodeInvalidValue identifies an invalid typed Kconfig scalar. ErrorCodeInvalidValue ErrorCode = "invalid-value" // ErrorCodeInvalidJSONValue identifies malformed or type-incompatible Value JSON. ErrorCodeInvalidJSONValue ErrorCode = "invalid-json-value" // ErrorCodeUnknownValueType identifies an unsupported ValueType. ErrorCodeUnknownValueType ErrorCode = "unknown-value-type" // ErrorCodeRootPath identifies failure to resolve the configured project root. ErrorCodeRootPath ErrorCode = "root-path" // ErrorCodeIncludeEscape identifies an include path that escapes the project root. ErrorCodeIncludeEscape ErrorCode = "include-escape" // ErrorCodeIncludeCycle identifies a cycle in source includes. ErrorCodeIncludeCycle ErrorCode = "include-cycle" // ErrorCodeSourceRead identifies a non-optional SourceLoader read failure. ErrorCodeSourceRead ErrorCode = "source-read" // ErrorCodeUnresolvedVariable identifies a missing caller-supplied variable. ErrorCodeUnresolvedVariable ErrorCode = "unresolved-variable" // ErrorCodeShellMacro identifies a disabled shell macro expansion. ErrorCodeShellMacro ErrorCode = "shell-macro" // ErrorCodeEnvironmentMacro identifies a disabled, disallowed, or missing environment macro lookup. ErrorCodeEnvironmentMacro ErrorCode = "environment-macro" // ErrorCodePythonMacro identifies a forbidden Python macro expansion. ErrorCodePythonMacro ErrorCode = "python-macro" // ErrorCodeCustomMacro identifies a forbidden custom macro expansion. ErrorCodeCustomMacro ErrorCode = "custom-macro" // ErrorCodeMacroExecution identifies a shell, Python, or custom macro execution failure. ErrorCodeMacroExecution ErrorCode = "macro-execution" // ErrorCodeMacroSyntax identifies malformed or excessively nested macro syntax. ErrorCodeMacroSyntax ErrorCode = "macro-syntax" // ErrorCodeUnsupportedMacro identifies an unsupported Kconfig macro expansion. ErrorCodeUnsupportedMacro ErrorCode = "unsupported-macro" // ErrorCodeIncompatibleSymbol identifies conflicting declared symbol types. ErrorCodeIncompatibleSymbol ErrorCode = "incompatible-symbol" // ErrorCodeUndeclaredSymbol identifies a symbol referenced without declaration. ErrorCodeUndeclaredSymbol ErrorCode = "undeclared-symbol" // ErrorCodeUninitializedProject identifies an operation on an uninitialized Project. ErrorCodeUninitializedProject ErrorCode = "uninitialized-project" // ErrorCodeUnknownSymbol identifies a submitted symbol absent from the project. ErrorCodeUnknownSymbol ErrorCode = "unknown-symbol" // ErrorCodeResolutionConvergence identifies resolution that cannot reach a fixed point. ErrorCodeResolutionConvergence ErrorCode = "resolution-convergence" // ErrorCodeInvalidState identifies a ConfigState unsuitable for an operation. ErrorCodeInvalidState ErrorCode = "invalid-state" // ErrorCodeMissingRootDocument identifies a Project without a root document. ErrorCodeMissingRootDocument ErrorCode = "missing-root-document" // ErrorCodeUnsafeConfigOutput identifies a .config value or symbol name // that is unsafe for the restrictive writer to emit for Make consumption. ErrorCodeUnsafeConfigOutput ErrorCode = "unsafe-config-output" )
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is a parsed Kconfig conditional expression.
type FSLoader ¶
type FSLoader struct{}
FSLoader is the default SourceLoader implementation backed by the host filesystem.
type FrontendInput ¶
type FrontendInput struct {
// Values maps declared symbol IDs to proposed frontend scalar values.
Values map[string]any
}
FrontendInput contains raw frontend scalars keyed by SymbolID. Resolve and Apply choose the target type from the loaded Kconfig symbol and normalize these forms internally: bool -> bool, tristate -> "n"/"m"/"y", string -> string, int -> an integral number, and hex -> a "0x..." string.
type FrontendTree ¶
type FrontendTree struct {
// Title is the project title used by the root screen.
Title string
// RootScreenID is the stable ID of the always-present root screen.
RootScreenID string
// Screens are rendered in static parent-before-child order.
Screens []Screen
// Diagnostics carries loading or rendering diagnostics relevant to this projection.
Diagnostics Diagnostics
}
FrontendTree is the complete dynamic projection of a Project for one ConfigState.
type LoadOptions ¶
type LoadOptions struct {
// Root confines entry and include paths when the default filesystem loader is used.
Root string
// Loader optionally replaces filesystem reads with an application-provided source store.
Loader SourceLoader
// Variables supplies literal $(NAME) and ${NAME} substitutions. Its values are
// never evaluated as shell, Python, environment, or custom macros.
Variables map[string]string
// Macros explicitly enables selected function-like macro forms. Its zero value
// rejects every function-like macro and does not execute host code.
Macros MacroOptions
}
type MacroFunc ¶ added in v1.3.0
MacroFunc expands the arguments of an explicitly enabled $(macro,...) call. It receives the command-bounded Load context, so it must return when the context is cancelled. Callers own validation and escaping of every argument: passing untrusted data to a macro can introduce security risks.
type MacroOptions ¶ added in v1.3.0
type MacroOptions struct {
// Environment is the exact allow-list for $(env,NAME) lookups.
Environment []string
// Shell enables $(shell,command).
Shell bool
// Python enables $(python,script).
Python bool
// ShellCommand overrides the shell executable and fixed argument prefix.
// When empty, Load uses cmd.exe /C on Windows and /bin/sh -c elsewhere.
ShellCommand []string
// PythonCommand overrides the Python executable and fixed argument prefix.
// Load appends -c and the macro script. When empty, it uses python -c.
PythonCommand []string
// CommandTimeout bounds enabled shell, Python, and custom macro work. A zero
// value uses 30 seconds; an earlier Load context deadline always wins.
CommandTimeout time.Duration
// Macro enables $(macro,arg1,arg2) and receives its expanded arguments.
Macro MacroFunc
}
MacroOptions controls the optional function-like macros evaluated during Load. The zero value is safe: it permits only literal Variables substitution.
Environment allows exact environment variable names for $(env,NAME). Shell, Python, and Macro independently enable $(shell,command), $(python,script), and $(macro,arg1,arg2). Enabled Shell and Python commands inherit the host environment and execute with LoadOptions.Root as their working directory. Do not interpolate untrusted input into any enabled macro; validation and escaping are caller responsibilities and execution always carries risk.
type Node ¶
type Node struct {
// ID is the stable declaration entry ID; SymbolID is the submitted-value key when applicable.
ID, SymbolID string
// SelectedSymbolID identifies the active choice member for choice nodes.
SelectedSymbolID string
// Kind determines how a frontend presents this node.
Kind NodeKind
// Prompt and Help are source-authored display text.
Prompt, Help string
// Visible controls display, while Enabled controls whether frontend edits are accepted.
Visible, Enabled bool
// Value is resolved state and Default is the active Kconfig default.
Value, Default Value
// Constraints describes valid user input at this state.
Constraints Constraints
// Reason explains hidden or disabled state when applicable.
Reason *StateReason
// Screen references the enterable child screen opened by this node, when any.
Screen *ScreenRef
// Source locates the original declaration.
Source SourceSpan
}
Node is a rendered entry with its current value, visibility, and interaction constraints.
type NodeKind ¶
type NodeKind uint8
NodeKind identifies a rendered frontend entry.
const ( // NodeConfig renders an ordinary configuration symbol. NodeConfig NodeKind = iota // NodeMenuConfig renders a configuration symbol that may open a child screen. NodeMenuConfig // NodeMenu renders a non-value menu entry that opens a child screen. NodeMenu // NodeChoice renders a group whose member symbols are the submitted values. NodeChoice // NodeComment renders non-interactive explanatory text. NodeComment )
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
Project is an immutable, indexed Kconfig document tree ready for resolution and rendering.
func (*Project) Apply ¶
func (p *Project) Apply(state ConfigState, patch FrontendInput) Resolution
Apply preserves valid prior user input from state, overlays patch, and resolves the complete next state.
func (*Project) OpenScreen ¶
func (p *Project) OpenScreen(state ConfigState, id string, options RenderOptions) ScreenResult
OpenScreen returns a visible, enterable screen, falling back to an ancestor or root when id is stale or hidden.
func (*Project) Render ¶
func (p *Project) Render(state ConfigState, options RenderOptions) FrontendTree
Render projects state into frontend screens without changing the state or Project.
func (*Project) Resolve ¶
func (p *Project) Resolve(input FrontendInput) Resolution
Resolve applies raw frontend input to fresh defaults and converges Kconfig dependencies, relations, and choices.
func (*Project) Schema ¶
Schema returns the full static catalog, including entries hidden by current conditions.
func (*Project) Validate ¶
func (p *Project) Validate(state ConfigState, symbolID string, candidate any) ValidationResult
Validate checks a raw frontend scalar without mutating state. Its accepted scalar forms are the same as FrontendInput.Values.
type Property ¶
type Property struct {
// Kind is the canonical Kconfig property keyword.
Kind string
// Text is the normalized property body without the keyword.
Text string
// Span locates the property in its source document.
Span SourceSpan
}
Property records one source property in declaration order. It intentionally keeps only normalized text: writers are canonical rather than format-preserving.
type RangeRule ¶
type RangeRule struct {
// Min and Max are inclusive bounds expressed in the symbol's declared type.
Min Value
Max Value
// Condition controls whether this range is active; nil means unconditional.
Condition Expr
// Span locates the range declaration in its source document.
Span SourceSpan
}
RangeRule limits an integer or hexadecimal symbol while Condition is active.
type Relation ¶
type Relation struct {
// Target is the symbol name changed by this relation.
Target string
// Condition controls when the relation is active; nil means unconditional.
Condition Expr
// Span locates the relation in its source document.
Span SourceSpan
}
Relation is a conditional select or imply target.
type RenderOptions ¶
type RenderOptions struct {
// IncludeHidden retains nodes and screens whose visibility conditions are false.
IncludeHidden bool
}
RenderOptions controls which presentation-only entries Render returns.
type Resolution ¶
type Resolution struct {
// State is the fully resolved immutable-by-convention configuration state.
State ConfigState
// Tree is the complete dynamic frontend projection for State.
Tree FrontendTree
// Changes is keyed by symbol ID and describes every submitted or normalized value.
Changes map[string]Change
// Diagnostics collects malformed input and resolution diagnostics.
Diagnostics Diagnostics
}
Resolution combines the resolved state, dynamic tree, per-symbol outcomes, and diagnostics.
type Schema ¶
type Schema struct {
// Title is the project title declared with mainmenu, or the default title.
Title string
// Symbols lists each declared configuration symbol and every declaration site.
Symbols []SymbolSchema
// Entries lists static menu-tree entries, independent of runtime visibility.
Entries []EntrySchema
// Screens lists navigable menu and menuconfig screens in parent-before-child order.
Screens []ScreenSchema
}
Schema is a static, cacheable catalog. Visibility and constraints belong to FrontendTree and are deliberately absent here.
type Screen ¶
type Screen struct {
// ID, ParentID, and OwnerID form the navigation hierarchy.
ID, ParentID, OwnerID string
// Title is the display label for this screen.
Title string
// Breadcrumb lists the visible root-to-screen navigation path.
Breadcrumb []ScreenRef
// Visible reports presentation visibility; Enterable reports whether navigation is allowed.
Visible, Enterable bool
// Entries contains this screen's rendered nodes in source order.
Entries []Node
}
Screen groups visible nodes that a frontend can navigate to.
type ScreenRef ¶
type ScreenRef struct{ ID, Title string }
ScreenRef identifies a screen without embedding its entries.
type ScreenResult ¶
type ScreenResult struct {
// Screen is the visible screen ultimately selected for the request.
Screen Screen
// ActiveScreenID repeats Screen.ID as a convenient navigation result.
ActiveScreenID string
// Redirected reports that the requested ID was stale or hidden.
Redirected bool
// Reason explains the redirect or project error, when applicable.
Reason *StateReason
// Tree is the complete projection used to find the selected screen.
Tree FrontendTree
}
ScreenResult combines a rendered tree with the screen selected after fallback.
type ScreenSchema ¶
type ScreenSchema struct {
// ID is the stable screen identity used by rendering and navigation.
ID string
// ParentID identifies the containing screen, or is empty for the root screen.
ParentID string
// OwnerID identifies the entry that opens this screen, or is empty for root.
OwnerID string
// Title is the screen label derived from its owning entry.
Title string
// Source locates the owning source entry when the screen is not root.
Source SourceSpan
}
ScreenSchema describes a static navigable screen and its ownership relation.
type Severity ¶
type Severity uint8
Severity describes how a diagnostic affects loading or resolution.
type Source ¶
type Source struct {
// Path identifies the source for diagnostics and include resolution.
Path string
// Data contains the complete UTF-8 Kconfig document.
Data []byte
}
Source is Kconfig text returned by a SourceLoader or supplied directly.
type SourceLoader ¶
SourceLoader permits applications to provide Kconfig files from an embedded filesystem or another trusted store. The loader receives a cleaned path rooted under LoadOptions.Root; it is never asked to expand Kconfig macros.
type SourceSpan ¶
type SourceSpan struct {
// Path is the document path supplied by the loader.
Path string
// Line and Column are one-based start coordinates.
Line int
Column int
// EndLine and EndColumn are optional one-based exclusive end coordinates.
EndLine int
EndColumn int
}
SourceSpan identifies a position in a Kconfig source file.
type StateReason ¶
type StateReason struct {
// Code is a stable machine-readable reason category.
Code string
// Message is a user-facing explanation for the current state.
Message string
// Source identifies the related declaration when available.
Source SourceSpan
}
StateReason explains why a value, node, or screen is unavailable or redirected.
type SymbolLookup ¶
SymbolLookup obtains the current value of a named symbol.
type SymbolSchema ¶
type SymbolSchema struct {
// ID is the submitted-value key used by FrontendInput.Values.
ID string
// Type controls the scalar form accepted for the symbol.
Type ValueType
// Source is the first declaration location for the symbol.
Source SourceSpan
// EntryIDs identifies every static declaration entry for the symbol.
EntryIDs []string
}
SymbolSchema describes one logical symbol that may have several declarations.
type Token ¶
type Token struct {
// Kind identifies the token category.
Kind TokenKind
// Text is the original token spelling.
Text string
// Span identifies the token's source position.
Span SourceSpan
}
Token is a source-positioned expression token.
type TokenKind ¶
type TokenKind uint8
TokenKind identifies a lexical unit in a Kconfig expression.
const ( // TokenEOF marks the end of an expression token stream. TokenEOF TokenKind = iota // TokenIdent is a symbol name or tristate literal spelling. TokenIdent // TokenString is a quoted Kconfig string literal. TokenString // TokenNumber is a decimal or hexadecimal numeric literal. TokenNumber // TokenNot is the unary ! operator. TokenNot // TokenAnd is the && logical operator. TokenAnd // TokenOr is the || logical operator. TokenOr // TokenEqual is the = comparison operator. TokenEqual // TokenNotEqual is the != comparison operator. TokenNotEqual // TokenLess is the < comparison operator. TokenLess // TokenLessEqual is the <= comparison operator. TokenLessEqual // TokenGreater is the > comparison operator. TokenGreater // TokenGreaterEqual is the >= comparison operator. TokenGreaterEqual // TokenLParen is an opening parenthesis. TokenLParen // TokenRParen is a closing parenthesis. TokenRParen )
type TriState ¶
type TriState uint8
TriState is the Kconfig n < m < y lattice value.
func EvalExpr ¶
func EvalExpr(expr Expr, lookup SymbolLookup) TriState
EvalExpr evaluates a parsed expression using Kconfig tristate logic.
type ValidationResult ¶
type ValidationResult struct {
// Accepted reports whether candidate is immediately valid in state.
Accepted bool
// Normalized is candidate when accepted, otherwise the suggested active default.
Normalized Value
// AllowedValues contains current toggles, tristates, or choice members.
AllowedValues []ValueOption
// Reason explains rejection without requiring state mutation.
Reason *StateReason
// Diagnostics provides parsing warnings for malformed frontend scalar forms.
Diagnostics Diagnostics
// AffectedEntryIDs identifies static declarations that a frontend may refresh.
AffectedEntryIDs []string
}
ValidationResult reports whether a proposed raw scalar is accepted and how a caller should recover when it is not.
type Value ¶
type Value struct {
// Type selects which of Tri, Text, or Int is meaningful.
Type ValueType
// Tri stores bool and tristate values.
Tri TriState
// Text stores string values without Kconfig quote syntax.
Text string
// Int stores decimal and hexadecimal integer values.
Int int64
}
Value is a typed Kconfig value. Only the field matching Type is meaningful.
func StringValue ¶
StringValue creates a string Value without adding Kconfig quote syntax.
func (Value) MarshalJSON ¶
MarshalJSON writes the frontend scalar form of a typed Kconfig value. A caller obtains the value type from Schema or Node.Constraints rather than having to decode the Value struct's implementation fields.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON accepts the scalar form emitted by MarshalJSON. When the receiver already carries a type (for example, ZeroValue(schema.Type)), JSON types are checked strictly. An untyped receiver infers only unambiguous scalar forms; callers with a string/tristate or int/hex ambiguity should initialize the receiver from schema metadata first.
type ValueOption ¶
type ValueOption struct {
// Value is the scalar choice value; for choices it is the member's resolved value.
Value Value
// SymbolID identifies a choice member when this option represents one.
SymbolID string
// Prompt is the human-readable label for the option or choice member.
Prompt string
// Selected reports whether the option is active in the current state.
Selected bool
// Enabled reports whether the frontend may submit this option.
Enabled bool
// Reason explains why an unavailable option is disabled.
Reason *StateReason
}
ValueOption describes a value or choice member available to the frontend.
type ValueOrigin ¶
type ValueOrigin uint8
ValueOrigin records why a resolved value was chosen.
const ( // OriginZero marks the initial inactive value before resolution. OriginZero ValueOrigin = iota // OriginDefault marks a value selected by an active default rule. OriginDefault // OriginInput marks a value provided directly by the frontend. OriginInput // OriginRelation marks a value raised by select or imply. OriginRelation // OriginChoice marks a value selected or cleared to satisfy a choice. OriginChoice )
type ValueType ¶
type ValueType uint8
ValueType is the declared type of a Kconfig symbol.
const ( // TypeUnknown marks an unset or invalid type. TypeUnknown ValueType = iota // TypeBool accepts only n or y. TypeBool // TypeTristate accepts n, m, or y. TypeTristate // TypeString stores quoted Kconfig string values. TypeString // TypeInt stores signed decimal integers. TypeInt // TypeHex stores non-negative hexadecimal integers. TypeHex )
type WriteConfigOptions ¶ added in v1.2.0
type WriteConfigOptions struct {
// TrustInput disables restrictive validation of string values and symbol
// names. It must be set only when every Kconfig declaration and configuration
// value producer is trusted; Make or shell consumers may interpret the
// resulting output. Serialization remains canonical and quoted.
TrustInput bool
}
WriteConfigOptions controls how WriteConfigWithOptions validates .config output before it can be consumed by GNU Make.