Skip to content

feat(cargo-wdk): add --target-platform option to the build command#683

Open
svasista-ms wants to merge 11 commits into
microsoft:mainfrom
svasista-ms:infverif-mode
Open

feat(cargo-wdk): add --target-platform option to the build command#683
svasista-ms wants to merge 11 commits into
microsoft:mainfrom
svasista-ms:infverif-mode

Conversation

@svasista-ms

@svasista-ms svasista-ms commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Pull request overview

Adds an explicit --target-platform switch to cargo wdk build so users can control which InfVerif validation mode is used when verifying the pacakge's INF.

The option mirrors the Target Platform setting in Visual Studio (Configuration Properties → Driver Settings):

--target-platform InfVerif mode Validates against
desktop /h WHQL signature requirements
universal (default) /u Universal driver requirements
windows-driver /w Windows Driver requirements

Changes

  • Introduces the --target-platform CLI argument (kebab-case, case-insensitive) and plumbs it through BuildAction into PackageTask.
  • Adds a TargetPlatform enum that maps each platform to its InfVerif mode flag.
  • Updates the tests and README.

⚠️ Behavior change

When --target-platform is not specified, the InfVerif mode now defaults to universal (/u) for all driver models, matching the Visual Studio's defaults.

Previously the mode was derived from the driver model (KMDF/WDM/w, UMDF/u). KMDF/WDM drivers built without the new flag will now be validated with /u instead of /w. To retain the previous validation, pass --target-platform windows-driver.

Notes

  • InfVerif accepts only one mode at a time, so --target-platform selects exactly one.
  • Support for additional InfVerif switches (e.g. /rulever, /wbuild) via an --infverif-args passthrough is intentionally deferred to a follow-up PR, where it can include validation to prevent specifying multiple modes.

Screenshots

image

Resolves #490.

Copilot AI review requested due to automatic review settings June 17, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit --target-platform switch to cargo wdk build so users can control which InfVerif mode flag is used (/h, /u, /w), addressing the “Desktop drivers need /h” scenario from #490.

Changes:

  • Introduces --target-platform CLI argument and plumbs it through BuildAction into PackageTask.
  • Adds a TargetPlatform enum and uses it to select the infverif mode flag (with UMDF default behavior conditional on detected WDK build number).
  • Updates tests and README documentation to cover the new option and the default derivation logic.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
crates/cargo-wdk/src/cli.rs Adds --target-platform parsing and maps CLI enum to internal TargetPlatform.
crates/cargo-wdk/src/actions/build/mod.rs Threads target_platform through build action params into packaging.
crates/cargo-wdk/src/actions/build/package_task.rs Implements TargetPlatform and uses it to select InfVerif mode flag; adds UMDF build-number-based default and tests.
crates/cargo-wdk/src/actions/build/tests.rs Extends build-action tests to cover overriding InfVerif mode via target_platform.
crates/cargo-wdk/README.md Documents the new flag and how default InfVerif mode is derived.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/README.md Outdated
@svasista-ms svasista-ms changed the title feat: add --target-platform option to build command to set InfVerif mode feat(cargo-wdk): add --target-platform option to build command to set InfVerif mode Jun 17, 2026
@codecov-commenter

codecov-commenter commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.40%. Comparing base (21ec8f8) to head (6e3c59f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #683      +/-   ##
==========================================
+ Coverage   79.93%   80.40%   +0.46%     
==========================================
  Files          26       26              
  Lines        5633     5751     +118     
  Branches     5633     5751     +118     
==========================================
+ Hits         4503     4624     +121     
+ Misses       1002      999       -3     
  Partials      128      128              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@svasista-ms svasista-ms marked this pull request as draft June 17, 2026 07:48
Copilot AI review requested due to automatic review settings June 22, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/cli.rs Outdated
@svasista-ms svasista-ms requested a review from Copilot June 24, 2026 04:56
@svasista-ms svasista-ms marked this pull request as ready for review June 24, 2026 04:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread crates/cargo-wdk/src/cli.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/tests.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/actions/build/mod.rs Outdated
Comment thread crates/cargo-wdk/src/cli.rs Outdated
Signed-off-by: Gurinder Singh <gurisingh@microsoft.com>
Copilot AI review requested due to automatic review settings July 1, 2026 04:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread crates/cargo-wdk/src/actions/build/package_task.rs Outdated
Comment thread crates/cargo-wdk/src/cli.rs Outdated
Comment thread crates/cargo-wdk/README.md
Comment thread crates/cargo-wdk/src/cli.rs Outdated
Comment on lines +47 to +48
/// Validates that the INF meets Universal driver requirements (using
/// `InfVerif /u`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These per-variant args are also AI slop. We should remove them just like in the other struct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Comment thread crates/cargo-wdk/src/cli.rs Outdated
Comment thread crates/cargo-wdk/README.md
Comment thread crates/cargo-wdk/src/cli.rs Outdated
}
}

fn assert_default_infverif_mode_flag(

@gurry gurry Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an almost complete duplicate of assert_target_platform_infverif_mode_flag. Instead of these two methods, we can have a single method which takes, driver_model, target_platform and expected_mode_flag e.g.:

fn assert_infverif_mode_flag(
    driver_model: DriverConfig,
    target_platform: TargetPlatform,
    expected_mode_flag: &'static str,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Comment thread crates/cargo-wdk/src/cli.rs
Comment thread crates/cargo-wdk/src/cli.rs Outdated
/// Driver signing mode.
/// Driver target platform.
#[arg(long, value_enum, ignore_case = true)]
pub target_platform: Option<TargetPlatformArg>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get rid of the Option and declare it simply as TargetPlatformArg if you accept copilot's suggestion above (https://github.com/microsoft/windows-drivers-rs/pull/683/changes#r3503312712)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed ✅

@svasista-ms svasista-ms changed the title feat(cargo-wdk): add --target-platform option to build command to set InfVerif mode feat(cargo-wdk): add --target-platform option to the build command Jul 1, 2026
Copilot AI review requested due to automatic review settings July 1, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread crates/cargo-wdk/src/actions/build/package_task.rs
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs
Comment thread crates/cargo-wdk/src/actions/build/package_task.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo wdk build: Support InfVerif /h (Desktop Drivers) in addition to InfVerif /w (Windows Drivers)

5 participants