feat: add cargo-wdk cargo extension#306
Conversation
Merge cargo-wdk/main as pf 12-02-25 with commit sha c59fff2
…rType, Profile, TargetArch, and fix tests
…rtain args case insensitive
…ith ignore case attribute
…ve an unnecessary debug statement
8a3937d to
7114f29
Compare
…e as part of another issue microsoft#363
removes tokio@1.44.1 from the dependency tree
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new cargo-wdk Cargo subcommand that streamlines creation and building of Windows Rust driver projects using the WDK and windows-drivers-rs.
- Adds a CLI binary (
cargo-wdk) withnewandbuildactions and an abstraction layer for file/command providers. - Implements logging (
tracemodule) and a verbosity-to-cargo-flag mapper. - Provides mockable providers (
fs,exec,metadata,wdk_build) and scaffolding templates for driver projects.
Reviewed Changes
Copilot reviewed 85 out of 85 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
templates/build.rs.tmp |
Build script template for driver crates |
src/trace.rs |
Tracing initialization and cargo-verbose-flag mapping |
src/providers/{fs,exec,metadata,wdk_build}.rs |
Mockable wrappers around std and external crates |
src/actions/new/mod.rs |
NewAction scaffolds driver project using templates |
src/actions/build/build_task.rs |
BuildTask runs cargo build for driver packages |
src/main.rs |
CLI entrypoint integrating trace and Cli::run |
README.md |
User guide for installing and using cargo-wdk |
CI workflows & Makefile.toml |
Added dependency sorting task and updated build jobs |
Cargo.toml files |
Workspace, dependency, and lint configurations updated |
Comments suppressed due to low confidence (3)
crates/cargo-wdk/src/actions/new/mod.rs:182
- [nitpick] The variable
lib_rs_pathholds the path tobuild.rs; it would be clearer to rename it tobuild_rs_path.
let lib_rs_path = self.path.join("build.rs");
crates/cargo-wdk/src/main.rs:14
- [nitpick] Importing
Okfromanyhowis unnecessary and can shadow the standardOkvariant; you can remove it and just importResult.
use anyhow::{Ok, Result};
crates/cargo-wdk/src/trace.rs:50
- There are no unit tests for
get_cargo_verbose_flags(orinit_tracing). Adding tests would ensure the verbosity-to-flag mappings remain correct as this logic evolves.
pub fn get_cargo_verbose_flags<'a>(
wmmc88
left a comment
There was a problem hiding this comment.
still going thru it. will come back for more review later today, but feel free to merge so we can get some mileage on this and address outstanding issues in followup
gurry
left a comment
There was a problem hiding this comment.
Happy to see us reach the first milstone. Great work @krishnakumar4a4 and @svasista-ms.
1. limits targets to be installed on the build pipeline 2. Minor doc fixes 3. remove lto for dev build 4. rename var
6c0d48a
|
@wmmc88 As discussed in our last call, Could you please make necessary changes to the pipeline configuration to avoid these pending builds |

cargo-wdkis a Command-Line Interface (CLI) utility that can be used to create and build Windows driver projects that depend on the WDK andwindows-drivers-rsplatform. It aims to streamline management of Rust drivers. It provides an easy and a consistent way to get started with Rust driver projects and build them using simple commands. It eliminates a lengthy setup process and also the need to maintain additional files/tools (Makefiles for cargo-make) to build/package the drivers.Commands -
newcommand generates a new driver project (KMDF/UMDF/WDM) from scratch using pre-determined templates.buildcommand compiles and packages drivers. The driver packaging flow is similar to the workflow defined incrates/wdk-build/rust-driver-makefile.toml(and in Visual Studio to build C/C++ drivers).The tool is tested to -
newcommand./examplesand the/testsfolders using thebuild commandWindows-rust-driver-samplesworkspaceMore information on installation and usage of
cargo-wdkin available undercrates/cargo-wdk/README.mdNOTE:
cargo-wdkneeds WDK to be installed on the system. The most preferred way is to enter an eWDK prompt.Related PRs