Home

Awesome

<div align="center"> <br> <img alt="Tux, the pinguin" src="./doc/tux.png" width=100px /> <h1>A Kconfig parser written in rust.</h1> </div>

Build status Code coverage Minimum supported rust version: 1.65.0 or plus crates.io Version

Kconfig is a language that describes configuration options for the Linux Kernel. The syntax looks like this:

# https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L771
config EFI
	bool "UEFI runtime support"
	depends on MMU
	default y
	select EFI_STUB
	help
	  This option provides support for runtime services provided
	  by UEFI firmware.

There are plenty of other keywords in the Kconfig language, check out the official documentation for more details.

Features

Getting started

cargo add nom-kconfig
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()?;
    let kconfig = parse_kconfig(KconfigInput::new_extra(&input, kconfig_file));
    println!("{:?}", kconfig);
    Ok(())
}

Resources