mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-30 15:34:33 +01:00
xtask: Cleanup check and build
This commit is contained in:
parent
91be97d33f
commit
8b3aa7f346
1 changed files with 68 additions and 101 deletions
|
@ -63,6 +63,13 @@ impl Backends {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
|
enum BuildOrCheck {
|
||||||
|
#[default]
|
||||||
|
Check,
|
||||||
|
Build,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
/// RTIC xtask powered testing toolbox
|
/// RTIC xtask powered testing toolbox
|
||||||
|
@ -345,19 +352,29 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
Commands::Check(args) => {
|
Commands::Check(args) => {
|
||||||
info!("Checking on backend: {backend:?}");
|
info!("Checking on backend: {backend:?}");
|
||||||
cargo(&cli.command, &cargologlevel, &args, backend)?;
|
cargo(BuildOrCheck::Check, &cargologlevel, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::Build(args) => {
|
Commands::Build(args) => {
|
||||||
info!("Building for backend: {backend:?}");
|
info!("Building for backend: {backend:?}");
|
||||||
cargo_build(&cargologlevel, &args, backend)?;
|
cargo(BuildOrCheck::Build, &cargologlevel, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::ExampleCheck => {
|
Commands::ExampleCheck => {
|
||||||
info!("Checking on backend: {backend:?}");
|
info!("Checking on backend: {backend:?}");
|
||||||
example_check(&cargologlevel, backend, &examples_to_run)?;
|
cargo_example(
|
||||||
|
BuildOrCheck::Check,
|
||||||
|
&cargologlevel,
|
||||||
|
backend,
|
||||||
|
&examples_to_run,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
Commands::ExampleBuild => {
|
Commands::ExampleBuild => {
|
||||||
info!("Building for backend: {backend:?}");
|
info!("Building for backend: {backend:?}");
|
||||||
example_build(&cargologlevel, backend, &examples_to_run)?;
|
cargo_example(
|
||||||
|
BuildOrCheck::Build,
|
||||||
|
&cargologlevel,
|
||||||
|
backend,
|
||||||
|
&examples_to_run,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
Commands::Size(arguments) => {
|
Commands::Size(arguments) => {
|
||||||
// x86_64 target not valid
|
// x86_64 target not valid
|
||||||
|
@ -388,75 +405,74 @@ fn main() -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cargo_build(
|
fn cargo(
|
||||||
|
operation: BuildOrCheck,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
package: &Package,
|
package: &Package,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let packages_to_check = package_filter(package);
|
|
||||||
if packages_to_check.contains(&"rtic".to_owned()) {
|
|
||||||
// rtic crate has features which needs special handling
|
// rtic crate has features which needs special handling
|
||||||
let s = format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
let rtic_features = &format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
||||||
let features: Option<&str> = Some(&s);
|
let features: Option<&str>;
|
||||||
|
let packages = package_filter(package);
|
||||||
|
features = if packages.contains(&"rtic".to_owned()) {
|
||||||
|
Some(&rtic_features)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
command_parser(
|
let command = match operation {
|
||||||
&CargoCommand::Build {
|
BuildOrCheck::Check => CargoCommand::Check {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: packages_to_check,
|
package: packages,
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features,
|
features,
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
BuildOrCheck::Build => CargoCommand::Build {
|
||||||
)?;
|
|
||||||
} else {
|
|
||||||
command_parser(
|
|
||||||
&CargoCommand::Build {
|
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: package_filter(package),
|
package: packages,
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features: None,
|
features,
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
};
|
||||||
)?;
|
command_parser(&command, false)?;
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cargo_check(
|
fn cargo_example(
|
||||||
|
operation: BuildOrCheck,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
package: &Package,
|
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
|
examples: &[String],
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let packages_to_check = package_filter(package);
|
|
||||||
if packages_to_check.contains(&"rtic".to_owned()) {
|
|
||||||
// rtic crate has features which needs special handling
|
|
||||||
let s = format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
let s = format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
||||||
let features: Option<&str> = Some(&s);
|
let features: Option<&str> = Some(&s);
|
||||||
|
|
||||||
command_parser(
|
examples.into_par_iter().for_each(|example| {
|
||||||
&CargoCommand::Check {
|
let command = match operation {
|
||||||
|
BuildOrCheck::Check => CargoCommand::ExampleCheck {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: package_filter(package),
|
example,
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features,
|
features,
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
BuildOrCheck::Build => CargoCommand::ExampleBuild {
|
||||||
)?;
|
|
||||||
} else {
|
|
||||||
command_parser(
|
|
||||||
&CargoCommand::Check {
|
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: package_filter(package),
|
example,
|
||||||
target: backend.to_target(),
|
target: backend.to_target(),
|
||||||
features: None,
|
features,
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
false,
|
};
|
||||||
)?;
|
|
||||||
|
if let Err(err) = command_parser(&command, false) {
|
||||||
|
error!("{err}");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,55 +570,6 @@ fn run_test(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn example_check(
|
|
||||||
cargoarg: &Option<&str>,
|
|
||||||
backend: Backends,
|
|
||||||
examples: &[String],
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let s = format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
|
||||||
let features: Option<&str> = Some(&s);
|
|
||||||
|
|
||||||
examples.into_par_iter().for_each(|example| {
|
|
||||||
let cmd = CargoCommand::ExampleCheck {
|
|
||||||
cargoarg,
|
|
||||||
example,
|
|
||||||
target: backend.to_target(),
|
|
||||||
features,
|
|
||||||
mode: BuildMode::Release,
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = command_parser(&cmd, false) {
|
|
||||||
error!("{err}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn example_build(
|
|
||||||
cargoarg: &Option<&str>,
|
|
||||||
backend: Backends,
|
|
||||||
examples: &[String],
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let s = format!("{},{}", DEFAULT_FEATURES, backend.to_rtic_feature());
|
|
||||||
let features: Option<&str> = Some(&s);
|
|
||||||
|
|
||||||
examples.into_par_iter().for_each(|example| {
|
|
||||||
let cmd = CargoCommand::ExampleBuild {
|
|
||||||
cargoarg,
|
|
||||||
example,
|
|
||||||
target: backend.to_target(),
|
|
||||||
features,
|
|
||||||
mode: BuildMode::Release,
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = command_parser(&cmd, false) {
|
|
||||||
error!("{err}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_and_check_size(
|
fn build_and_check_size(
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
|
|
Loading…
Reference in a new issue