From f6976b84ed000fb0bae40e296e91b7296a8d8aae Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Fri, 1 Aug 2025 18:05:47 +0530 Subject: [PATCH 1/2] fix: remove `--cwd` arg from `cargo-wdk` `--cwd` is not an argument on `cargo build`. It has `--manifest-path` instead. Since we are emulating `cargo build` we should expose the same UX. This PR only removes `--cwd`. Will add `--manifest-path` at some later point because it is not something very commonly used. --- .github/workflows/build.yaml | 6 ++++-- crates/cargo-wdk/README.md | 6 ------ crates/cargo-wdk/src/cli.rs | 8 ++------ crates/cargo-wdk/tests/build_command_test.rs | 2 +- crates/cargo-wdk/tests/new_command_test.rs | 7 ++----- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a6db1fcb2..49a39e1ea 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -97,7 +97,9 @@ jobs: run: cargo +${{ matrix.rust_toolchain }} install --path=crates/cargo-wdk --profile ${{ matrix.cargo_profile }} --locked --force - name: Build & Package Examples (via cargo-wdk) - run: cargo +${{ matrix.rust_toolchain }} wdk build --cwd ./examples --profile ${{ matrix.cargo_profile }} --target-arch ${{ matrix.target_triple.arch }} --sample + run: cargo +${{ matrix.rust_toolchain }} wdk build --profile ${{ matrix.cargo_profile }} --target-arch ${{ matrix.target_triple.arch }} --sample + working-directory: ./examples - name: Run build on tests folder (via cargo-wdk) - run: cargo +${{ matrix.rust_toolchain }} wdk build --cwd ./tests --profile ${{ matrix.cargo_profile }} --target-arch ${{ matrix.target_triple.arch }} + run: cargo +${{ matrix.rust_toolchain }} wdk build --profile ${{ matrix.cargo_profile }} --target-arch ${{ matrix.target_triple.arch }} + working-directory: ./tests diff --git a/crates/cargo-wdk/README.md b/crates/cargo-wdk/README.md index e37df2649..c59d653e1 100644 --- a/crates/cargo-wdk/README.md +++ b/crates/cargo-wdk/README.md @@ -82,12 +82,6 @@ The recommended way to do this is to [enter an eWDK developer prompt](https://le cargo wdk build ``` - * With `--cwd` - - ```pwsh - cargo wdk build --cwd /path/to/project - ``` - * With `--target-arch` ```pwsh diff --git a/crates/cargo-wdk/src/cli.rs b/crates/cargo-wdk/src/cli.rs index ef5b71759..a43106604 100644 --- a/crates/cargo-wdk/src/cli.rs +++ b/crates/cargo-wdk/src/cli.rs @@ -3,7 +3,7 @@ //! This module defines the top-level CLI layer, its argument types and //! structures used for parsing and validating arguments for various //! subcommands. -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use anyhow::{Ok, Result}; use clap::{ArgGroup, Args, Parser, Subcommand}; @@ -78,10 +78,6 @@ impl NewArgs { /// Arguments for the `build` subcommand #[derive(Debug, Args)] pub struct BuildArgs { - /// Path to the project - #[arg(long, default_value = ".")] - pub cwd: PathBuf, - /// Build artifacts with the specified profile #[arg(long, ignore_case = true)] pub profile: Option, @@ -160,7 +156,7 @@ impl Cli { }; let build_action = BuildAction::new( &BuildActionParams { - working_dir: &cli_args.cwd, + working_dir: Path::new("."), // Using current dir as working dir profile: cli_args.profile.as_ref(), target_arch, verify_signature: cli_args.verify_signature, diff --git a/crates/cargo-wdk/tests/build_command_test.rs b/crates/cargo-wdk/tests/build_command_test.rs index a44f5bcc3..ba3f733c1 100644 --- a/crates/cargo-wdk/tests/build_command_test.rs +++ b/crates/cargo-wdk/tests/build_command_test.rs @@ -115,7 +115,7 @@ fn run_build_cmd(driver_path: &str) -> String { set_crt_static_flag(); let mut cmd = Command::cargo_bin("cargo-wdk").expect("unable to find cargo-wdk binary"); - cmd.args(["build", "--cwd", driver_path]); + cmd.args(["build"]).current_dir(driver_path); // assert command output let cmd_assertion = cmd.assert().success(); diff --git a/crates/cargo-wdk/tests/new_command_test.rs b/crates/cargo-wdk/tests/new_command_test.rs index 56b6d3e62..b6705a3d8 100644 --- a/crates/cargo-wdk/tests/new_command_test.rs +++ b/crates/cargo-wdk/tests/new_command_test.rs @@ -193,11 +193,8 @@ fn create_and_build_new_driver_project(driver_type: &str) -> (String, String) { set_crt_static_flag(); let mut cmd = Command::cargo_bin("cargo-wdk").expect("unable to find cargo-wdk binary"); - cmd.args([ - "build", - "--cwd", - &tmp_dir.join(&driver_name).to_string_lossy(), // Root dir for tests is cargo-wdk - ]); + let driver_path = tmp_dir.join(&driver_name); // Root dir for tests + cmd.args(["build"]).current_dir(&driver_path); let cmd_assertion = cmd.assert().failure(); tmp_dir From 6316b9adc141b5c952a8317c20c705e37b2c115c Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Wed, 6 Aug 2025 14:10:54 +0530 Subject: [PATCH 2/2] Remove another mention of cwd --- crates/cargo-wdk/src/actions/new/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/cargo-wdk/src/actions/new/mod.rs b/crates/cargo-wdk/src/actions/new/mod.rs index 7e7451fe9..9ca7fdb7d 100644 --- a/crates/cargo-wdk/src/actions/new/mod.rs +++ b/crates/cargo-wdk/src/actions/new/mod.rs @@ -41,10 +41,9 @@ impl<'a> NewAction<'a> { /// /// # Arguments /// - /// * `driver_project_name` - The name of the driver project to be created. + /// * `path` - The path to the new driver project. The last part of the path + /// is used as the package name. /// * `driver_type` - The type of the driver project to be created. - /// * `cwd` - The current working directory inside which driver project will - /// be created. /// * `verbosity_level` - The verbosity level for logging. /// * `command_exec` - The provider for command exection. /// * `fs` - The provider for file system operations.