feat: add manifest options support for cargo build invocations#656
feat: add manifest options support for cargo build invocations#656svasista-ms wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for forwarding Cargo “manifest options” (--locked, --offline, --frozen) from cargo wdk build down to the underlying Cargo build invocations, improving reproducibility/offline support.
Changes:
- Introduces a
ManifestOptionsclap args struct and exposes it on thebuildCLI via#[command(flatten)]. - Threads
ManifestOptionsthroughBuildAction/BuildTaskand forwards flags tocargo buildandcargo rustc. - Adds/updates unit tests to validate the forwarding behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/cargo-wdk/src/cli.rs | Adds flattened manifest-related CLI flags to the build subcommand and passes them into the build action. |
| crates/cargo-wdk/src/actions/mod.rs | Defines ManifestOptions and a helper to convert the selected options into Cargo CLI args. |
| crates/cargo-wdk/src/actions/build/mod.rs | Stores/propagates ManifestOptions within BuildAction and forwards them to cargo rustc target-probing. |
| crates/cargo-wdk/src/actions/build/build_task.rs | Forwards ManifestOptions into the cargo build command args; adds focused tests for forwarding. |
| crates/cargo-wdk/src/actions/build/tests.rs | Extends build action tests to cover manifest option forwarding in higher-level orchestration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
==========================================
+ Coverage 79.45% 79.85% +0.40%
==========================================
Files 26 26
Lines 5500 5610 +110
Branches 5500 5610 +110
==========================================
+ Hits 4370 4480 +110
Misses 1001 1001
Partials 129 129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Confirm fixed ordering: locked before offline before frozen | ||
| let locked_idx = args.iter().position(|a| *a == "--locked").unwrap(); | ||
| let offline_idx = args.iter().position(|a| *a == "--offline").unwrap(); | ||
| let frozen_idx = args.iter().position(|a| *a == "--frozen").unwrap(); |
| impl ManifestOptions { | ||
| /// Returns an iterator over the cargo CLI flags equivalent to this set of | ||
| /// options. | ||
| pub fn cargo_args(&self) -> impl Iterator<Item = &'static str> { |
There was a problem hiding this comment.
| pub fn cargo_args(&self) -> impl Iterator<Item = &'static str> { | |
| pub fn as_cargo_args(&self) -> impl Iterator<Item = &'static str> { |
Slightly more idiomatic
| } | ||
|
|
||
| #[test] | ||
| fn kmdf_driver_builds_successfully_with_offline_flag() { |
There was a problem hiding this comment.
Add a test for --locked as well
|
|
||
| - To build a driver project with a strict, reproducible dependency lockfile (e.g. for CI), navigate to the root of the project and run: | ||
|
|
||
| ```pwsh | ||
| cargo wdk build --locked | ||
| ``` |
There was a problem hiding this comment.
This is example is not needed. We don't need to add examples for every commandline line arg
| ``` | ||
|
|
||
| `build` takes a number of inputs specifying build profile (`dev` or `release`), target architecture (`amd64` or `arm64`), a flag enabling signature verification and a flag indicating a sample driver along with verbosity flags. | ||
| `build` takes a number of inputs specifying build profile (`dev` or `release`), target architecture (`amd64` or `arm64`), a flag enabling signature verification and a flag indicating a sample driver along with verbosity flags. It also accepts the cargo manifest flags `--locked`, `--offline` and `--frozen`, which are forwarded to the underlying `cargo` invocations (e.g. `cargo build`, `cargo metadata`). |
There was a problem hiding this comment.
| `build` takes a number of inputs specifying build profile (`dev` or `release`), target architecture (`amd64` or `arm64`), a flag enabling signature verification and a flag indicating a sample driver along with verbosity flags. It also accepts the cargo manifest flags `--locked`, `--offline` and `--frozen`, which are forwarded to the underlying `cargo` invocations (e.g. `cargo build`, `cargo metadata`). | |
| `build` takes a number of inputs specifying build profile (`dev` or `release`), target architecture (`amd64` or `arm64`), a flag enabling signature verification and a flag indicating a sample driver along with verbosity flags. It also accepts cargo manifest flags `--locked`, `--offline` and `--frozen`, which are forwarded to `cargo`. |
Slightly shorter
This PR adds support for forwarding Cargo “manifest options” (--locked, --offline, --frozen) from
cargo wdk builddown to the underlying Cargo build invocations, improving reproducibility/offline support.Resolves #648
Changes
ManifestOptionsclapargsstruct and exposes it on the build CLI via #[command(flatten)] [1]cargo metadata,cargo buildandcargo rustcinvocations in the build action. [2] [3] [4]Screenshots
cargo wdk build --helpshowing Manifest Options:cargo wdk build --locked --sampleon the/examplesemulated workspace: