windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

Validate parameters supplied to the cargo-wdk build command

Open svasista-ms opened this issue 4 months ago • 3 comments

The build subcommand currently constructs and runs BuildAction with minimal upfront checks. Many user errors aren’t surfaced until after WDK detection, PATH setup, or partial per‑package iteration. Early validation will produce faster, clearer failures and simplify BuildAction.

Currently CLI parses flags (profile, target-arch, verify-signature, sample) but does not:

  1. Check driver intent flags (--verify-signature, --sample) against actual driver packages.
  2. Check that selected target arch is installed. (Nice to have)
  3. Check the mode of the workspace earlier, i.e. Standalone, Workspace or Emulated. (Happens inside BuildAction::run)

We could add a preflight for build in the CLI layer which can:

  • Absolutize the working directory
  • Determine workspace mode: Single/Workspace or Emulated
  • Load Cargo Metadata Once (for Single/Workspace Mode) and use it in BuildAction. If there is no Metadata we could check for emulated workspace scenario.
  • From the workspace we could identify the members that are driver projects (i.e metadata.wdk is present and crate type is cdylib). If there are no driver members, the --verify and --sample flag do not make sense. It can be ignored.
  • Optionally we could also probe rustup target list --installed to check if target is installed and fail early.

This may allow us to reorder some of BuildAction::run such as WDK Build # detection and PATH setup can be done after confirming at least one driver package will be built. Fetching cargo metadata would happen once prebuild and will be used throughout.

Originally posted by @wmmc88 in https://github.com/microsoft/windows-drivers-rs/pull/462#discussion_r2299774350

svasista-ms avatar Aug 26 '25 11:08 svasista-ms

@svasista-ms when you create these issues from PR comments, please make sure there is sufficient context in them

wmmc88 avatar Aug 26 '25 17:08 wmmc88

I have updated the description with more details. Please feel free to change the title if it does not reflect the intent fully.

@gurry , @krishnakumar4a4, could you please review the issue and add your comments if any? Thank you!

svasista-ms avatar Aug 27 '25 10:08 svasista-ms

I have updated the description with more details. Please feel free to change the title if it does not reflect the intent fully.

@gurry , @krishnakumar4a4, could you please review the issue and add your comments if any? Thank you!

This issue is pretty broad. We will probably need to create sub-issues for specific areas. I have added one existing issue as a sub-issue for now.

gurry avatar Oct 14 '25 04:10 gurry