Skip to content

feat: add manifest options support for cargo build invocations#656

Open
svasista-ms wants to merge 5 commits into
microsoft:mainfrom
svasista-ms:648-support-locked-option
Open

feat: add manifest options support for cargo build invocations#656
svasista-ms wants to merge 5 commits into
microsoft:mainfrom
svasista-ms:648-support-locked-option

Conversation

@svasista-ms
Copy link
Copy Markdown
Contributor

@svasista-ms svasista-ms commented May 12, 2026

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.

Resolves #648

Changes

  1. Introduces a ManifestOptions clap args struct and exposes it on the build CLI via #[command(flatten)] [1]
  2. Threads ManifestOptions through BuildAction/BuildTask and forwards flags to cargo metadata, cargo build and cargo rustc invocations in the build action. [2] [3] [4]
  3. Adds/updates unit tests and one system level test to validate the forwarding behavior. [5] [6]

Screenshots

  1. cargo wdk build --help showing Manifest Options:
image
  1. cargo wdk build --locked --sample on the /examples emulated workspace:
image

Copilot AI review requested due to automatic review settings May 12, 2026 09:05
Copy link
Copy Markdown
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 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 ManifestOptions clap args struct and exposes it on the build CLI via #[command(flatten)].
  • Threads ManifestOptions through BuildAction/BuildTask and forwards flags to cargo build and cargo 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.

Comment thread crates/cargo-wdk/src/actions/mod.rs
Comment thread crates/cargo-wdk/src/actions/build/tests.rs
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2026

Codecov Report

❌ Patch coverage is 99.12281% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.85%. Comparing base (74b1da7) to head (b57d075).

Files with missing lines Patch % Lines
crates/cargo-wdk/src/actions/build/mod.rs 85.71% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings May 13, 2026 07:57
Copy link
Copy Markdown
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread crates/cargo-wdk/src/providers/metadata.rs
Copilot AI review requested due to automatic review settings May 21, 2026 04:43
Copy link
Copy Markdown
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@svasista-ms svasista-ms marked this pull request as ready for review May 21, 2026 06:55
Comment on lines +391 to +394
// 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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does order matter?

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> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a test for --locked as well

Comment on lines +121 to +126

- 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
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
`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

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.

Support --locked passthrough in cargo wdk

4 participants