From 63b7024cb98717dd785ae888f419002b9835c6b1 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Fri, 14 Apr 2023 23:59:23 +0200 Subject: xtask: build usage examples and general improvements --- xtask/src/cargo_commands.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'xtask/src/cargo_commands.rs') 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, +) -> Vec> { + 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 -- cgit v1.2.3