feat(cargo-wdk): add --target-platform option to the build command#683
feat(cargo-wdk): add --target-platform option to the build command#683svasista-ms wants to merge 11 commits into
--target-platform option to the build command#683Conversation
There was a problem hiding this comment.
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-platformCLI argument and plumbs it throughBuildActionintoPackageTask. - Adds a
TargetPlatformenum and uses it to select theinfverifmode 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.
--target-platform option to build command to set InfVerif mode--target-platform option to build command to set InfVerif mode
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…if mode handling + update README
…rget platform options
…ldActionParams and PackageTaskParams
Signed-off-by: Gurinder Singh <gurisingh@microsoft.com>
| /// Validates that the INF meets Universal driver requirements (using | ||
| /// `InfVerif /u`). |
There was a problem hiding this comment.
These per-variant args are also AI slop. We should remove them just like in the other struct
| } | ||
| } | ||
|
|
||
| fn assert_default_infverif_mode_flag( |
There was a problem hiding this comment.
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,
)| /// Driver signing mode. | ||
| /// Driver target platform. | ||
| #[arg(long, value_enum, ignore_case = true)] | ||
| pub target_platform: Option<TargetPlatformArg>, |
There was a problem hiding this comment.
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)
--target-platform option to build command to set InfVerif mode--target-platform option to the build command
Pull request overview
Adds an explicit
--target-platformswitch tocargo wdk buildso users can control whichInfVerifvalidation mode is used when verifying the pacakge's INF.The option mirrors the Target Platform setting in Visual Studio (Configuration Properties → Driver Settings):
--target-platformdesktop/huniversal(default)/uwindows-driver/wChanges
--target-platformCLI argument (kebab-case, case-insensitive) and plumbs it throughBuildActionintoPackageTask.TargetPlatformenum that maps each platform to itsInfVerifmode flag.When
--target-platformis not specified, theInfVerifmode now defaults touniversal(/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/uinstead of/w. To retain the previous validation, pass--target-platform windows-driver.Notes
InfVerifaccepts only one mode at a time, so--target-platformselects exactly one.InfVerifswitches (e.g./rulever,/wbuild) via an--infverif-argspassthrough is intentionally deferred to a follow-up PR, where it can include validation to prevent specifying multiple modes.Screenshots
Resolves #490.