diff --git a/xtask/src/argument_parsing.rs b/xtask/src/argument_parsing.rs index 69275eb338..738168e16a 100644 --- a/xtask/src/argument_parsing.rs +++ b/xtask/src/argument_parsing.rs @@ -19,15 +19,17 @@ impl fmt::Display for Package { } impl Package { - pub fn name(&self) -> &str { - match self { + pub fn name(&self) -> String { + let name = match self { Package::Rtic => "rtic", Package::RticCommon => "rtic-common", Package::RticMacros => "rtic-macros", Package::RticMonotonics => "rtic-monotonics", Package::RticSync => "rtic-sync", Package::RticTime => "rtic-time", - } + }; + + name.to_string() } pub fn all() -> Vec { @@ -102,33 +104,33 @@ impl TestMetadata { ); let features = Some(backend.to_target().and_features(&features)); CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features, test: Some("ui".to_owned()), } } Package::RticMacros => CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features: Some(backend.to_rtic_macros_feature().to_owned()), test: None, }, Package::RticSync => CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features: Some("testing".to_owned()), test: None, }, Package::RticCommon => CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features: Some("testing".to_owned()), test: None, }, Package::RticMonotonics => CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features: None, test: None, }, Package::RticTime => CargoCommand::Test { - package: Some(package), + package: Some(package.name()), features: Some("critical-section/std".into()), test: None, }, diff --git a/xtask/src/cargo_commands.rs b/xtask/src/cargo_commands.rs index ec91eae0da..c290e95742 100644 --- a/xtask/src/cargo_commands.rs +++ b/xtask/src/cargo_commands.rs @@ -114,14 +114,14 @@ pub fn cargo<'c>( let command = match operation { BuildOrCheck::Check => CargoCommand::Check { cargoarg, - package: Some(package), + package: Some(package.name()), target, features, mode: BuildMode::Release, }, BuildOrCheck::Build => CargoCommand::Build { cargoarg, - package: Some(package), + package: Some(package.name()), target, features, mode: BuildMode::Release, @@ -224,7 +224,7 @@ pub fn cargo_clippy<'c>( globals, CargoCommand::Clippy { cargoarg, - package: Some(package), + package: Some(package.name()), target, features, }, @@ -247,7 +247,7 @@ pub fn cargo_format<'c>( globals, CargoCommand::Format { cargoarg, - package: Some(p), + package: Some(p.name()), check_only, }, false, diff --git a/xtask/src/command.rs b/xtask/src/command.rs index e06c89ea0c..da6d9074b6 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -1,8 +1,8 @@ use log::{error, info, Level}; use crate::{ - argument_parsing::Globals, cargo_commands::FinalRunResult, ExtraArguments, Package, RunResult, - Target, TestRunError, + argument_parsing::Globals, cargo_commands::FinalRunResult, ExtraArguments, RunResult, Target, + TestRunError, }; use core::fmt; use std::{ @@ -70,27 +70,27 @@ pub enum CargoCommand<'a> { }, Build { cargoarg: &'a Option<&'a str>, - package: Option, + package: Option, target: Target<'a>, features: Option, mode: BuildMode, }, Check { cargoarg: &'a Option<&'a str>, - package: Option, + package: Option, target: Target<'a>, features: Option, mode: BuildMode, }, Clippy { cargoarg: &'a Option<&'a str>, - package: Option, + package: Option, target: Target<'a>, features: Option, }, Format { cargoarg: &'a Option<&'a str>, - package: Option, + package: Option, check_only: bool, }, Doc { @@ -99,7 +99,7 @@ pub enum CargoCommand<'a> { arguments: Option, }, Test { - package: Option, + package: Option, features: Option, test: Option, }, @@ -127,7 +127,7 @@ pub enum CargoCommand<'a> { impl core::fmt::Display for CargoCommand<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let p = |p: &Option| { + let p = |p: &Option| { if let Some(package) = p { format!("package {package}") } else { @@ -468,7 +468,7 @@ impl<'a> CargoCommand<'a> { args.extend_from_slice(&[self.command(), "--target", target.triple()]); if let Some(package) = package { - args.extend_from_slice(&["--package", package.name()]); + args.extend_from_slice(&["--package", package]); } if let Some(feature) = features { @@ -493,7 +493,7 @@ impl<'a> CargoCommand<'a> { args.extend_from_slice(&[self.command()]); if let Some(package) = package { - args.extend_from_slice(&["--package", package.name()]); + args.extend_from_slice(&["--package", package]); } if let Some(feature) = features { @@ -518,7 +518,7 @@ impl<'a> CargoCommand<'a> { args.extend_from_slice(&[self.command()]); if let Some(package) = package { - args.extend_from_slice(&["--package", package.name()]); + args.extend_from_slice(&["--package", package]); } if let Some(feature) = features { @@ -557,7 +557,7 @@ impl<'a> CargoCommand<'a> { args.extend_from_slice(&[self.command()]); if let Some(package) = package { - args.extend_from_slice(&["--package", package.name()]); + args.extend_from_slice(&["--package", package]); } if let Some(feature) = features { @@ -594,7 +594,7 @@ impl<'a> CargoCommand<'a> { } if let Some(package) = package { - args.extend_from_slice(&["--package", package.name()]); + args.extend_from_slice(&["--package", package]); } if *check_only { args.extend_from_slice(&["--check"]); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 853dbe783c..0043474ab2 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -3,7 +3,7 @@ mod build; mod cargo_commands; mod command; -use argument_parsing::{ExtraArguments, Globals, Package}; +use argument_parsing::{ExtraArguments, Globals}; use clap::Parser; use command::OutputMode; use core::fmt;