feat: add linker args for VHF lib to wdk-build#653
feat: add linker args for VHF lib to wdk-build#653Alan632 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in vhf feature to wdk-build so driver crates can automatically link the appropriate Virtual HID Framework (VHF) import library without hardcoding linker directives in their own build.rs.
Changes:
- Add a
vhfCargo feature towdk-build. - When
vhfis enabled, emitVhfKm.libfor WDM/KMDF builds andVhfUm.libfor UMDF builds via build script output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/wdk-build/src/lib.rs |
Emits VHF linker input per driver type under #[cfg(feature = "vhf")]. |
crates/wdk-build/Cargo.toml |
Defines the new vhf feature flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #653 +/- ##
=======================================
Coverage 78.69% 78.69%
=======================================
Files 25 25
Lines 5234 5234
Branches 5234 5234
=======================================
Hits 4119 4119
Misses 995 995
Partials 120 120 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Link against VhfKm.lib (Virtual HID Framework, kernel-mode) when | ||
| // the "vhf" feature is enabled. Required by drivers that create | ||
| // virtual HID devices. | ||
| #[cfg(feature = "vhf")] |
There was a problem hiding this comment.
we shouldn't need to introduce a new feature to wdk-build for this. vhf headers are tied to the HID API subset, and so linking of the vhf libraries should also be tied to that API subset. Look at how the API subsets are threaded thru from the features in wdk-sys and see how we can maybe have this automatically link in the relevant libraries.
Keep in mind that linker directives must still happen only for the final binary
Description
Add linker arguments for the VHF library (feature gated) to the build script output for each driver type so drivers using the VHF don't have to hardcode the output in their own build scripts.
wdk-build/lib.rswdk-build/Cargo.tomlvhffeatureVerification
Built a driver and ensured vhf linker args were still in build
outputafter removing the hardcoded line in the driver'sbuild.rs.