mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 12:12:50 +01:00
CargoCommand can take any package
This commit is contained in:
parent
9dc9f49263
commit
404867cdf9
4 changed files with 29 additions and 27 deletions
|
@ -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<Self> {
|
||||
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>,
|
||||
package: Option<String>,
|
||||
target: Target<'a>,
|
||||
features: Option<String>,
|
||||
mode: BuildMode,
|
||||
},
|
||||
Check {
|
||||
cargoarg: &'a Option<&'a str>,
|
||||
package: Option<Package>,
|
||||
package: Option<String>,
|
||||
target: Target<'a>,
|
||||
features: Option<String>,
|
||||
mode: BuildMode,
|
||||
},
|
||||
Clippy {
|
||||
cargoarg: &'a Option<&'a str>,
|
||||
package: Option<Package>,
|
||||
package: Option<String>,
|
||||
target: Target<'a>,
|
||||
features: Option<String>,
|
||||
},
|
||||
Format {
|
||||
cargoarg: &'a Option<&'a str>,
|
||||
package: Option<Package>,
|
||||
package: Option<String>,
|
||||
check_only: bool,
|
||||
},
|
||||
Doc {
|
||||
|
@ -99,7 +99,7 @@ pub enum CargoCommand<'a> {
|
|||
arguments: Option<ExtraArguments>,
|
||||
},
|
||||
Test {
|
||||
package: Option<Package>,
|
||||
package: Option<String>,
|
||||
features: Option<String>,
|
||||
test: Option<String>,
|
||||
},
|
||||
|
@ -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<Package>| {
|
||||
let p = |p: &Option<String>| {
|
||||
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"]);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue