kconfig-rs 0.3.1

Build library for translating Kconfig into Rust cfgs
Documentation
  • Coverage
  • 6.67%
    1 out of 15 items documented0 out of 4 items with examples
  • Size
  • Source code size: 9.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.65 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexonea

kconfig-rs

Build library for translating Kconfig into Rust cfgs.

Given a .config, the kconfig-rs library generates rustc-cfg and rustc-check-cfg directives for conditional compilation. It does so by reading the .config file and translating options into Rust cfgs. Moreover, it generates a kconfig.rs file which may be included into the user crate for accesing typed versions of the configuration options defined in the .config file.

Usage

Add this package as a build dependency to your crate in Cargo.toml.

[build-dependencies]
kconfig-rs = "*"

In your build.rs script include the following invocation.

use kconfig_rs as kconfig;

fn main() {

	...

	kconfig::generate();

	...

}

It does not matter where in the main function, the generate function is called.

The CARGO_KCONFIG_DOTCONFIG environment variable must be set and pointing to the .config file. The path to the .config file must be absolute. Several packages might share the same .config file. One might generate .config files from Kconfig using cargo-menuconfig.

To access the typed versions of the configuration options, include the generated kconfig.rs file anywhere in your crate.

mod config {
	include!(concat!(env!(OUT_DIR), "/kconfig.rs"));
}

fn main() {
	do_something(config::CONFIG_FOO);
}

The cargo build system will automatically rerun when the .config file changes.

Contributing

Please send feature requests and bug reports to alexandru at onea dot ro.