Crate nom_kconfig

source ·
Expand description

nom-kconfig

A parser for kconfig files. The parsing is done with nom.

use std::path::PathBuf;
use nom_kconfig::{parse_kconfig, 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<dyn std::error::Error>> {
    let kconfig_file = KconfigFile::new(
        PathBuf::from("/tmp/linux-6.4.9"),
        PathBuf::from("/tmp/linux-6.4.9/Kconfig")
    );
    let input = kconfig_file.read_to_string().unwrap();
    let kconfig = parse_kconfig(KconfigInput::new_extra(&input, kconfig_file));
    println!("{:?}", kconfig);
    Ok(())
}

Re-exports

Modules

Macros

Structs

  • Represents a Kconfig file. It stores the kernel root directory because we need this information when a source keyword is met.

Type Definitions