mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
xtask: Reorder commands
This commit is contained in:
parent
a73a8d63cf
commit
ff49889890
2 changed files with 59 additions and 52 deletions
|
@ -54,6 +54,7 @@ pub enum CargoCommand<'a> {
|
||||||
package: Vec<String>,
|
package: Vec<String>,
|
||||||
target: &'a str,
|
target: &'a str,
|
||||||
features: Option<&'a str>,
|
features: Option<&'a str>,
|
||||||
|
mode: BuildMode,
|
||||||
},
|
},
|
||||||
Clippy {
|
Clippy {
|
||||||
cargoarg: &'a Option<&'a str>,
|
cargoarg: &'a Option<&'a str>,
|
||||||
|
@ -172,6 +173,7 @@ impl<'a> CargoCommand<'a> {
|
||||||
package,
|
package,
|
||||||
target,
|
target,
|
||||||
features,
|
features,
|
||||||
|
mode,
|
||||||
} => {
|
} => {
|
||||||
let mut args = vec!["+nightly"];
|
let mut args = vec!["+nightly"];
|
||||||
if let Some(cargoarg) = cargoarg {
|
if let Some(cargoarg) = cargoarg {
|
||||||
|
@ -187,6 +189,9 @@ impl<'a> CargoCommand<'a> {
|
||||||
if let Some(feature) = features {
|
if let Some(feature) = features {
|
||||||
args.extend_from_slice(&["--features", feature]);
|
args.extend_from_slice(&["--features", feature]);
|
||||||
}
|
}
|
||||||
|
if let Some(flag) = mode.to_flag() {
|
||||||
|
args.push(flag);
|
||||||
|
}
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
CargoCommand::Clippy {
|
CargoCommand::Clippy {
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl Backends {
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
/// RTIC xtask powered testing toolbox
|
/// RTIC xtask powered testing toolbox
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// For which backend to build
|
/// For which backend to build (defaults to thumbv7)
|
||||||
#[arg(value_enum, short, long)]
|
#[arg(value_enum, short, long)]
|
||||||
backend: Option<Backends>,
|
backend: Option<Backends>,
|
||||||
|
|
||||||
|
@ -100,6 +100,27 @@ struct Cli {
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
|
/// Check formatting
|
||||||
|
FormatCheck(Package),
|
||||||
|
|
||||||
|
/// Format code
|
||||||
|
Format(Package),
|
||||||
|
|
||||||
|
/// Run clippy
|
||||||
|
Clippy(Package),
|
||||||
|
|
||||||
|
/// Check all packages
|
||||||
|
Check(Package),
|
||||||
|
|
||||||
|
/// Build all packages
|
||||||
|
Build(Package),
|
||||||
|
|
||||||
|
/// Check all examples
|
||||||
|
ExampleCheck,
|
||||||
|
|
||||||
|
/// Build all examples
|
||||||
|
ExampleBuild,
|
||||||
|
|
||||||
/// Run `cargo size` on selected or all examples
|
/// Run `cargo size` on selected or all examples
|
||||||
///
|
///
|
||||||
/// To pass options to `cargo size`, add `--` and then the following
|
/// To pass options to `cargo size`, add `--` and then the following
|
||||||
|
@ -124,27 +145,6 @@ enum Commands {
|
||||||
/// Requires that an ARM target is selected
|
/// Requires that an ARM target is selected
|
||||||
Run(QemuAndRun),
|
Run(QemuAndRun),
|
||||||
|
|
||||||
/// Build all examples
|
|
||||||
ExampleBuild,
|
|
||||||
|
|
||||||
/// Check all packages
|
|
||||||
ExampleCheck,
|
|
||||||
|
|
||||||
/// Build all examples
|
|
||||||
Build(Package),
|
|
||||||
|
|
||||||
/// Check all packages
|
|
||||||
Check(Package),
|
|
||||||
|
|
||||||
/// Check formatting
|
|
||||||
FormatCheck(Package),
|
|
||||||
|
|
||||||
/// Format code
|
|
||||||
Format(Package),
|
|
||||||
|
|
||||||
/// Run clippy
|
|
||||||
Clippy(Package),
|
|
||||||
|
|
||||||
/// Build docs
|
/// Build docs
|
||||||
Doc,
|
Doc,
|
||||||
}
|
}
|
||||||
|
@ -329,6 +329,36 @@ fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
match cli.command {
|
match cli.command {
|
||||||
|
Commands::FormatCheck(args) => {
|
||||||
|
info!("Running cargo fmt: {args:?}");
|
||||||
|
let check_only = true;
|
||||||
|
cargo_format(&cargoarg, &args, check_only)?;
|
||||||
|
}
|
||||||
|
Commands::Format(args) => {
|
||||||
|
info!("Running cargo fmt --check: {args:?}");
|
||||||
|
let check_only = false;
|
||||||
|
cargo_format(&cargoarg, &args, check_only)?;
|
||||||
|
}
|
||||||
|
Commands::Clippy(args) => {
|
||||||
|
info!("Running clippy on backend: {backend:?}");
|
||||||
|
cargo_clippy(&cargoarg, &args, backend)?;
|
||||||
|
}
|
||||||
|
Commands::Check(args) => {
|
||||||
|
info!("Checking on backend: {backend:?}");
|
||||||
|
cargo_check(&cargoarg, &args, backend)?;
|
||||||
|
}
|
||||||
|
Commands::Build(args) => {
|
||||||
|
info!("Building for backend: {backend:?}");
|
||||||
|
cargo_build(&cargoarg, &args, backend)?;
|
||||||
|
}
|
||||||
|
Commands::ExampleCheck => {
|
||||||
|
info!("Checking on backend: {backend:?}");
|
||||||
|
example_check(&cargoarg, backend, &examples_to_run)?;
|
||||||
|
}
|
||||||
|
Commands::ExampleBuild => {
|
||||||
|
info!("Building for backend: {backend:?}");
|
||||||
|
example_build(&cargoarg, backend, &examples_to_run)?;
|
||||||
|
}
|
||||||
Commands::Size(arguments) => {
|
Commands::Size(arguments) => {
|
||||||
// x86_64 target not valid
|
// x86_64 target not valid
|
||||||
info!("Measuring for backend: {backend:?}");
|
info!("Measuring for backend: {backend:?}");
|
||||||
|
@ -349,40 +379,10 @@ fn main() -> anyhow::Result<()> {
|
||||||
args.overwrite_expected,
|
args.overwrite_expected,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
Commands::ExampleBuild => {
|
|
||||||
info!("Building for backend: {backend:?}");
|
|
||||||
example_build(&cargoarg, backend, &examples_to_run)?;
|
|
||||||
}
|
|
||||||
Commands::ExampleCheck => {
|
|
||||||
info!("Checking on backend: {backend:?}");
|
|
||||||
example_check(&cargoarg, backend, &examples_to_run)?;
|
|
||||||
}
|
|
||||||
Commands::Build(args) => {
|
|
||||||
info!("Building for backend: {backend:?}");
|
|
||||||
cargo_build(&cargoarg, &args, backend)?;
|
|
||||||
}
|
|
||||||
Commands::Check(args) => {
|
|
||||||
info!("Checking on backend: {backend:?}");
|
|
||||||
cargo_check(&cargoarg, &args, backend)?;
|
|
||||||
}
|
|
||||||
Commands::Clippy(args) => {
|
|
||||||
info!("Running clippy on backend: {backend:?}");
|
|
||||||
cargo_clippy(&cargoarg, &args, backend)?;
|
|
||||||
}
|
|
||||||
Commands::Doc => {
|
Commands::Doc => {
|
||||||
info!("Running cargo doc on backend: {backend:?}");
|
info!("Running cargo doc on backend: {backend:?}");
|
||||||
cargo_doc(&cargoarg, backend)?;
|
cargo_doc(&cargoarg, backend)?;
|
||||||
}
|
}
|
||||||
Commands::FormatCheck(args) => {
|
|
||||||
info!("Running cargo fmt: {args:?}");
|
|
||||||
let check_only = true;
|
|
||||||
cargo_format(&cargoarg, &args, check_only)?;
|
|
||||||
}
|
|
||||||
Commands::Format(args) => {
|
|
||||||
info!("Running cargo fmt --check: {args:?}");
|
|
||||||
let check_only = false;
|
|
||||||
cargo_format(&cargoarg, &args, check_only)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -441,6 +441,7 @@ fn cargo_check(
|
||||||
package: package_filter(package),
|
package: package_filter(package),
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features,
|
features,
|
||||||
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
@ -451,6 +452,7 @@ fn cargo_check(
|
||||||
package: package_filter(package),
|
package: package_filter(package),
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features: None,
|
features: None,
|
||||||
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
Loading…
Reference in a new issue