-
Notifications
You must be signed in to change notification settings - Fork 124
feat: add cargo wdk clean command
#638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 20 commits
b9db4c5
ef2d04e
4075932
9ce3a8e
4b58929
64e7bcc
fbf1c4b
9cbdc66
915366a
3fe851f
6bb2c93
b7e2469
6e1fe56
ed2a887
47285be
95a2721
3aee35d
730a953
80cc4ec
abf8412
8a5961a
5d37942
740225c
2567210
4cb3626
42a67e3
b23b0b7
90a8726
69f895e
3fd27e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,10 @@ impl<'a> BuildAction<'a> { | |
| metadata: &'a Metadata, | ||
| ) -> Result<Self> { | ||
| // TODO: validate params | ||
| anyhow::ensure!( | ||
| !params.working_dir.as_os_str().is_empty(), | ||
| "working_dir must not be empty" | ||
| ); | ||
| Ok(Self { | ||
| working_dir: absolute(params.working_dir)?, | ||
| profile: params.profile, | ||
|
|
@@ -151,14 +155,13 @@ impl<'a> BuildAction<'a> { | |
| ); | ||
|
|
||
| let mut is_valid_dir_with_rust_projects = false; | ||
| for dir in &dirs { | ||
| if self.fs.dir_file_type(dir)?.is_dir() | ||
| && self.fs.exists(&dir.path().join("Cargo.toml")) | ||
| { | ||
| for entry in &dirs { | ||
| if entry.is_dir && self.fs.exists(&entry.path.join("Cargo.toml")) { | ||
| debug!( | ||
| "Found atleast one valid Rust project directory: {}, continuing with the \ | ||
| build flow", | ||
| dir.path() | ||
| entry | ||
| .path | ||
| .file_name() | ||
| .expect( | ||
| "package sub directory name ended with \"..\" which is not expected" | ||
|
|
@@ -179,23 +182,21 @@ impl<'a> BuildAction<'a> { | |
| info!("Building packages in {}", self.working_dir.display()); | ||
|
|
||
| let mut failed_atleast_one_project = false; | ||
| for dir in dirs { | ||
| debug!("Checking dir entry: {}", dir.path().display()); | ||
| if !self.fs.dir_file_type(&dir)?.is_dir() | ||
| || !self.fs.exists(&dir.path().join("Cargo.toml")) | ||
| { | ||
| for entry in dirs { | ||
| debug!("Checking dir entry: {}", entry.path.display()); | ||
| if !entry.is_dir || !self.fs.exists(&entry.path.join("Cargo.toml")) { | ||
| debug!("Dir entry is not a valid Rust package"); | ||
| continue; | ||
| } | ||
|
|
||
| let working_dir_path = dir.path(); // Avoids a short-lived temporary | ||
| let working_dir_path = entry.path; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment even applies here as we are not really switching into the directory during this loop. https://github.com/microsoft/windows-drivers-rs/pull/638/changes#r3199700749
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed to |
||
| let sub_dir = working_dir_path | ||
| .file_name() | ||
| .expect("package sub directory name ended with \"..\" which is not expected") | ||
| .to_string_lossy(); | ||
|
|
||
| debug!("Building package(s) in dir {sub_dir}"); | ||
| if let Err(e) = self.run_from_workspace_root(&dir.path()) { | ||
| if let Err(e) = self.run_from_workspace_root(&working_dir_path) { | ||
| failed_atleast_one_project = true; | ||
| err!( | ||
| "Error building project: {sub_dir}, error: {:?}", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright (c) Microsoft Corporation | ||
| // License: MIT OR Apache-2.0 | ||
| //! This module defines error types for the clean action module. | ||
|
|
||
| use std::path::PathBuf; | ||
|
|
||
| use thiserror::Error; | ||
|
|
||
| use crate::providers::error::{CommandError, FileError}; | ||
|
|
||
| /// Errors for the clean action layer | ||
| #[derive(Error, Debug)] | ||
| pub enum CleanActionError { | ||
| #[error(transparent)] | ||
| FileIo(#[from] FileError), | ||
| #[error("No valid rust projects in the current working directory: {0}")] | ||
| NoValidRustProjectsInTheDirectory(PathBuf), | ||
| #[error("One or more projects failed to clean in the emulated workspace: {0}")] | ||
| OneOrMoreRustProjectsFailedToClean(PathBuf), | ||
| #[error(transparent)] | ||
| CargoClean(#[from] CommandError), | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.