Validate parameters supplied to the cargo-wdk build command
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:
- Check driver intent flags (--verify-signature, --sample) against actual driver packages.
- Check that selected target arch is installed. (Nice to have)
- 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 when you create these issues from PR comments, please make sure there is sufficient context in them
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!
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.