Skip to content

Allow conditional compilation based off of WDF version ranges #276

Open
@wmmc88

Description

@wmmc88

Currently, drivers built off of windows-drivers-rs only allow conditional compilation based off of driver type (example). This can be easily expanded to other parts of the Wdk config struct via adding those fields to EXPORTED_CFG_SETTINGS.

When adding cfg's for UMDF/KMDF Version, usability in driver code can be less than ideal. For example, it is not easy to conditional compile for Minor versions less than 7. Rust's cfg system only allows for cfg being equal to a value. Instead, you would have to have multiple cfg clauses for each value that are all "or"ed together via any.

Example:

#[cfg(any(driver_model__target_umdf_version_minor = "1", driver_model__target_umdf_version_minor = "2",driver_model__target_umdf_version_minor = "3",driver_model__target_umdf_version_minor = "4",driver_model__target_umdf_version_minor = "5",driver_model__target_umdf_version_minor = "6"))]
fn only_less_than_v7() {}

This is very painful to use. One possible solution to this could be to get wdk-build to generate some sort of cfg aliases for ranges via something like cfg_aliases.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions