cfg_feature_groups

Crates.iocfg_feature_groups
lib.rscfg_feature_groups
version0.1.1
sourcesrc
created_at2019-04-06 16:11:50.700644
updated_at2019-04-06 16:12:38.32383
descriptionBuild helper for defining feature groups
homepage
repositoryhttps://github.com/little-arhat/cfg-feature-groups
max_upload_size
id126182
size8,372
Tools (github:rust-embedded:tools)

documentation

README

cfg_feature_groups

define feature groups to improve conditional compilation management

Build Status crates.io

This library allows one to define feature group, that may only take one value out of set. Feature groups defined in Cargo.toml as metadata:

[package.metadata.feature_groups]
log = ["dummy", "semihosting", "itm"]

Where "dummy", "semihosting", "itm" are features defined separately. Once feature groups are defined, they can be checked during build time and turned into cfg attributes:

[build-dependencies]
cfg_feature_groups = "..."
use cfg_feature_groups::setup_feature_groups;
fn main() {
    setup_feature_groups();
}

Then in your program you may use something like this:

#[cfg(log = "itm")]
fn define_itm() {}

setup_feature_groups will ensure that one and only one option is defined for each feature group.

See full example.

Documentation

API Docs available on docs.rs.

License

See also

if_cfg crates provides alternative way to tackle conditional compilation.

Commit count: 8

cargo fmt