A Kconfig parser written in rust.
Parsing relies on the nom library.
Getting started
bash
cargo add nom-kconfig
```rust
use std::path::PathBuf;
use nomkconfig::{kconfig::parsekconfig, KconfigInput, KconfigFile};
// curl https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.9.tar.xz | tar -xJ -C /tmp/
fn main() -> Result<(), Box> {
let kconfigfile = KconfigFile::new(
PathBuf::from("/tmp/linux-6.4.9"),
PathBuf::from("/tmp/linux-6.4.9/Kconfig")
);
let input = kconfigfile.readtostring().unwrap();
let kconfig = parsekconfig(KconfigInput::newextra(&input, kconfig_file));
println!("{:?}", kconfig);
Ok(())
}
```
Resources
- https://www.kernel.org/doc/html/next/kbuild/kconfig-language.html
- https://doc.coreboot.org/getting_started/kconfig.html
- https://build2.org/libbuild2-kconfig/doc/build2-kconfig-manual.xhtml#lang