aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/cargo_commands.rs
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-14 23:59:23 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-16 13:08:46 +0200
commit63b7024cb98717dd785ae888f419002b9835c6b1 (patch)
treeb65d1bc57d1f10c76cb053542095668b94246f09 /xtask/src/cargo_commands.rs
parentcba786529a7e34ed623df5f7cde5aae762a8c55c (diff)
xtask: build usage examples and general improvements
Diffstat (limited to 'xtask/src/cargo_commands.rs')
-rw-r--r--xtask/src/cargo_commands.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/xtask/src/cargo_commands.rs b/xtask/src/cargo_commands.rs
index 9cbdaef..9b07088 100644
--- a/xtask/src/cargo_commands.rs
+++ b/xtask/src/cargo_commands.rs
@@ -126,6 +126,33 @@ pub fn cargo<'c>(
runner.run_and_coalesce()
}
+/// Cargo command to build a usage example.
+///
+/// The usage examples are in examples/
+pub fn cargo_usage_example(
+ globals: &Globals,
+ operation: BuildOrCheck,
+ usage_examples: Vec<String>,
+) -> Vec<FinalRunResult<'_>> {
+ examples_iter(&usage_examples)
+ .map(|example| {
+ let path = format!("examples/{example}");
+
+ let command = match operation {
+ BuildOrCheck::Check => CargoCommand::CheckInDir {
+ mode: BuildMode::Release,
+ dir: path.into(),
+ },
+ BuildOrCheck::Build => CargoCommand::BuildInDir {
+ mode: BuildMode::Release,
+ dir: path.into(),
+ },
+ };
+ (globals, command, false)
+ })
+ .run_and_coalesce()
+}
+
/// Cargo command to either build or check all examples
///
/// The examples are in rtic/examples