Skip to content

Comments

feat: add cargo-wdk cargo extension#306

Merged
gurry merged 190 commits intomicrosoft:mainfrom
svasista-ms:integrate-cargo-wdk
Jun 3, 2025
Merged

feat: add cargo-wdk cargo extension#306
gurry merged 190 commits intomicrosoft:mainfrom
svasista-ms:integrate-cargo-wdk

Conversation

@svasista-ms
Copy link
Contributor

@svasista-ms svasista-ms commented Feb 27, 2025

cargo-wdk is a Command-Line Interface (CLI) utility that can be used to create and build Windows driver projects that depend on the WDK and windows-drivers-rs platform. 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 -

  1. new command generates a new driver project (KMDF/UMDF/WDM) from scratch using pre-determined templates.
  2. build command compiles and packages drivers. The driver packaging flow is similar to the workflow defined in crates/wdk-build/rust-driver-makefile.toml (and in Visual Studio to build C/C++ drivers).

The tool is tested to -

  1. Create new driver projects by specifying a path and exactly one of the three driver types - KMDF, UMDF and WDM to the new command.
  2. Build /examples and the /tests folders using the build command
  3. Build workspaces with both driver and non-driver member packages.
  4. Windows-rust-driver-samples workspace

More information on installation and usage of cargo-wdk in available under crates/cargo-wdk/README.md

NOTE: cargo-wdk needs WDK to be installed on the system. The most preferred way is to enter an eWDK prompt.

Related PRs

svasista-ms and others added 30 commits February 11, 2025 08:23
Merge cargo-wdk/main as pf 12-02-25 with commit sha c59fff2
leon-xd
leon-xd previously approved these changes May 30, 2025
Copy link
Contributor

@leon-xd leon-xd left a comment

Choose a reason for hiding this comment

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

Great work!

@wmmc88 wmmc88 requested a review from Copilot May 30, 2025 22:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with new and build actions and an abstraction layer for file/command providers.
  • Implements logging (trace module) 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_path holds the path to build.rs; it would be clearer to rename it to build_rs_path.
let lib_rs_path = self.path.join("build.rs");

crates/cargo-wdk/src/main.rs:14

  • [nitpick] Importing Ok from anyhow is unnecessary and can shadow the standard Ok variant; you can remove it and just import Result.
use anyhow::{Ok, Result};

crates/cargo-wdk/src/trace.rs:50

  • There are no unit tests for get_cargo_verbose_flags (or init_tracing). Adding tests would ensure the verbosity-to-flag mappings remain correct as this logic evolves.
pub fn get_cargo_verbose_flags<'a>(

wmmc88
wmmc88 previously approved these changes May 31, 2025
Copy link
Collaborator

@wmmc88 wmmc88 left a comment

Choose a reason for hiding this comment

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

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
gurry previously approved these changes Jun 2, 2025
Copy link
Contributor

@gurry gurry left a comment

Choose a reason for hiding this comment

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

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
@krishnakumar4a4 krishnakumar4a4 dismissed stale reviews from gurry, wmmc88, and leon-xd via 6c0d48a June 2, 2025 10:54
@krishnakumar4a4
Copy link
Contributor

@wmmc88 As discussed in our last call, Could you please make necessary changes to the pipeline configuration to avoid these pending builds

image

@krishnakumar4a4 krishnakumar4a4 enabled auto-merge June 2, 2025 11:54
@krishnakumar4a4
Copy link
Contributor

krishnakumar4a4 commented Jun 2, 2025

Hi @wmmc88 & @leon-xd , It looks like the PR requires review and approval after a new commit. Could you please review the latest commit and approve again if all looks okay.

@krishnakumar4a4 krishnakumar4a4 added this pull request to the merge queue Jun 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 3, 2025
@gurry gurry added this pull request to the merge queue Jun 3, 2025
Merged via the queue into microsoft:main with commit 5b9aa0a Jun 3, 2025
63 checks passed
@gurry gurry deleted the integrate-cargo-wdk branch June 3, 2025 06:32
@leon-xd leon-xd mentioned this pull request Oct 17, 2025
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.

5 participants