Portable Kconfig core: typed dependency resolution, boolean choices and reproducible build configuration
moon add CYang-dep/moonkconfig@0.3.0import {
"CYang-dep/moonkconfig" @config,
}
pkgtype(kind: "executable")///|
fn main {
try {
let schema = @config.parse_kconfig("config ENABLE\n bool \"Enable\"\n default y\nconfig DEPTH\n int \"Depth\"\n range 1 32\n default 8")
let requests = schema.parse_config("CONFIG_DEPTH=16")
let result = schema.resolve(requests)
assert_eq(result.value("ENABLE"), @config.Logic(@config.Y))
assert_eq(result.value("DEPTH"), @config.Number(16L))
println(schema.export_config(result))
println(schema.export_header(result))
} catch {
_ => abort("configuration failed")
}
}moon run . --target jsmoon run examples/firmware --target js
moon run examples/variants --target js
moon run examples/ui --target jslet schema = @config.parse_linux612("Kconfig", files)
let (requests, diagnostics) = schema.read_linux_config("CONFIG_RIGHT=y")
ignore(diagnostics)
let result = schema.resolve(requests)
println(schema.export_linux_config(result))| 领域 | 固定版本语义 |
|---|---|
| 声明 | bool/tristate/string/int/hex,menu/menuconfig/if/comment/help,重复声明按遍历顺序合并并保留每个来源 |
| 表达式与值 | 三态逻辑、字符串词典序、带符号/无符号比较、保留数值原始文本与基数 |
| 预处理 | =、:=、+=,参数函数、嵌套展开、标准内建函数、文件/行号和显式环境/Shell 适配 |
| 源树 | 固定版本的字面 source 路径、循环诊断、条件继承;完整输入由宿主提供 |
| 求值 | 首个有效 default、depends on、select、imply、modules、匿名 bool choice、首个活动 range |
| 配置 | 宽松读取及诊断、重复有效赋值后写覆盖,最终配置的赋值省略与数值拼写 |
| LEFT | RIGHT | 显式 SHARED | 最终值 | 最终导出 |
|---|---|---|---|---|
| n | n | 无 | 0 | 省略 SHARED |
| y | n | 无 | 11 | CONFIG_SHARED=11 |
| n | y | 无 | 22 | CONFIG_SHARED=22 |
| y | y | 无 | 11 | CONFIG_SHARED=11 |
| n | y | 37 | 37 | CONFIG_SHARED=37 |
moon info
moon fmt --check
moon check --deny-warn --target js
moon test --deny-warn --target js
moon build --deny-warn --target js
python -m pip install kconfiglib==14.1.0
python tools/differential.py --target js
python tools/check_declarations.py --target js
python tools/audit.pygit clone --filter=blob:none --no-checkout https://github.com/torvalds/linux _oracle/linux
git -C _oracle/linux checkout adc218676eef25575469234709c2d87185ca223a
python tools/build_linux612.py --source _oracle/linux --output _oracle/build
python tools/linux612.py --source _oracle/linux --conf _oracle/build/conf --target js --report _oracle/report-js.json#deprecated("`ConfigError::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn ConfigError::to_repr(ConfigError) -> Repr#deprecated("`ConfigChange::equal` is deprecated, use `Eq::equal` instead.")
fn ConfigChange::equal(ConfigChange, ConfigChange) -> Bool#deprecated("`ConfigChange::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn ConfigChange::not_equal(x : ConfigChange, y : ConfigChange) -> Bool#deprecated("`ConfigChange::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn ConfigChange::to_repr(ConfigChange) -> Reprpub struct Fragment {
// private fields
}#deprecated("`OverlayConflict::equal` is deprecated, use `Eq::equal` instead.")
fn OverlayConflict::equal(OverlayConflict, OverlayConflict) -> Bool#deprecated("`OverlayConflict::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn OverlayConflict::not_equal(x : OverlayConflict, y : OverlayConflict) -> Bool#deprecated("`OverlayConflict::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn OverlayConflict::to_repr(OverlayConflict) -> Reprpub struct Preprocessor {
// private fields
}fn Preprocessor::new(environment? : Map[String, String], shell? : (String) -> String raise ConfigError, message? : (String, String) -> Unit) -> Preprocessorpub struct Resolution {
// private fields
}pub struct Schema {
// private fields
}fn Schema::add(self : Schema, name : String, kind : Kind, prompt? : String) -> Unit raise ConfigErrorfn Schema::changes(self : Schema, before : Resolution, after : Resolution) -> Array[ConfigChange] raise ConfigErrorfn Schema::default_value(self : Schema, name : String, value : Expr, condition? : Expr) -> Unit raise ConfigErrorfn Schema::read_linux_config(self : Schema, text : String) -> (Fragment, Array[String]) raise ConfigErrorfn Schema::request(self : Schema, requests : Fragment, name : String, value : Value) -> Unit raise ConfigErrorfn Schema::reverse_dependency(self : Schema, source : String, target : String, weak? : Bool, condition? : Expr) -> Unit raise ConfigError#deprecated("`SymbolView::equal` is deprecated, use `Eq::equal` instead.")
fn SymbolView::equal(SymbolView, SymbolView) -> Bool#deprecated("`SymbolView::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn SymbolView::not_equal(x : SymbolView, y : SymbolView) -> Bool#deprecated("`SymbolView::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn SymbolView::to_repr(SymbolView) -> Reprfn parse_linux612(entry : String, sources : Map[String, String], preprocessor? : Preprocessor) -> Schema raise ConfigErrorfn parse_sources(entry : String, sources : Map[String, String], preprocessor? : Preprocessor, linux612? : Bool) -> Schema raise ConfigErrorInstall
Download zipPortable Kconfig core: typed dependency resolution, boolean choices and reproducible build configuration