diff options
| author | Henrik Tjäder <henrik@tjaders.com> | 2023-02-04 16:55:29 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:35:14 +0100 |
| commit | 81ba62787cd099524baa553a6bc91d287680c5e4 (patch) | |
| tree | 8b084e985a90cba163781fdd9c7bd3d35be52415 /xtask/src/main.rs | |
| parent | 0f7e0e97360d448c3021afc254e47b7d52c6c2e8 (diff) | |
xtask: Make target flag optional, default to all targets
Diffstat (limited to 'xtask/src/main.rs')
| -rw-r--r-- | xtask/src/main.rs | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7c0ed20..2d259dc 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -32,10 +32,10 @@ struct Options { /// /// * thumbv7m-none-eabi #[structopt(short, long)] - target: String, + target: Option<String>, /// Example to run, by default all examples are run /// - /// Example: `cargo xtask --target <..> --example complex` + /// Example: `cargo xtask --example complex` #[structopt(short, long)] example: Option<String>, /// Enables also running `cargo size` on the selected examples @@ -43,7 +43,7 @@ struct Options { /// To pass options to `cargo size`, add `--` and then the following /// arguments will be passed on /// - /// Example: `cargo xtask --target <..> -s -- -A` + /// Example: `cargo xtask -s -- -A` #[structopt(short, long)] size: bool, /// Options to pass to `cargo size` @@ -147,19 +147,24 @@ fn main() -> anyhow::Result<()> { } init_build_dir()?; - if target == "all" { - for t in targets { - run_test(t, &examples, check_size, size_arguments)?; + match target { + None => { + for t in targets { + println!("Testing all targets: {targets:?}"); + run_test(t, &examples, check_size, size_arguments)?; + } + } + Some(target) => { + if targets.contains(&target.as_str()) { + run_test(target, &examples, check_size, size_arguments)?; + } else { + eprintln!( + "The target you specified is not available. Available targets are:\ + \n{targets:?}\n", + ); + process::exit(1); + } } - } else if targets.contains(&target.as_str()) { - run_test(target, &examples, check_size, size_arguments)?; - } else { - eprintln!( - "The target you specified is not available. Available targets are:\ - \n{targets:?}\n\ - as well as `all` (testing on all of the above)", - ); - process::exit(1); } Ok(()) |
