E5EA Add support for --workspace --exclude by michelhe · Pull Request #313 · LukeMathWalker/cargo-chef · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ pub struct Cook {
/// Build all members in the workspace.
#[arg(long)]
workspace: bool,
/// Exclude packages from the build
#[arg(long, requires = "workspace")]
exclude: Option<Vec<String>>,
/// Build offline.
#[arg(long)]
offline: bool,
Expand Down Expand Up @@ -185,6 +188,7 @@ fn _main() -> Result<(), anyhow::Error> {
manifest_path,
package,
workspace,
exclude,
offline,
frozen,
locked,
Expand Down Expand Up @@ -286,6 +290,7 @@ fn _main() -> Result<(), anyhow::Error> {
manifest_path,
package,
workspace,
exclude,
offline,
timings,
no_std,
Expand Down
13 changes: 13 additions & 0 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct CookArgs {
pub manifes A670 t_path: Option<PathBuf>,
pub package: Option<Vec<String>>,
pub workspace: bool,
pub exclude: Option<Vec<String>>,
pub offline: bool,
pub locked: bool,
pub frozen: bool,
Expand Down Expand Up @@ -108,6 +109,7 @@ fn build_dependencies(args: &CookArgs) {
manifest_path,
package,
workspace,
exclude,
offline,
frozen,
locked,
Expand Down Expand Up @@ -183,6 +185,17 @@ fn build_dependencies(args: &CookArgs) {
if *workspace {
command_with_args.arg("--workspace");
}
match (*workspace, exclude) {
(true, Some(exclude_list)) if !exclude_list.is_empty() => {
for exclude_item in exclude_list {
command_with_args.arg("--exclude").arg(exclude_item);
}
}
(false, Some(_)) => {
panic!("`--exclude` can only be used with `--workspace`");
}
_ => {}
}
if *offline {
command_with_args.arg("--offline");
}
Expand Down
0