diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-26 10:26:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-26 10:26:45 +0000 |
| commit | 5a4bcae1fb5c4cac7201e1f1a2bc131ca68d3952 (patch) | |
| tree | 1dc9f0a997050d6b59c98c546cdcd96f6506d78d /xtask/src/command.rs | |
| parent | 3a1d42b614309759d25fb2bf8c628a1c26159c83 (diff) | |
| parent | ef4e4aaaa3d261bda0aa46f89f2e6f8edefd202e (diff) | |
Merge #572
572: cargo xtask is now ~40x faster r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'xtask/src/command.rs')
| -rw-r--r-- | xtask/src/command.rs | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/xtask/src/command.rs b/xtask/src/command.rs index d94a7ab..2f719bf 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -1,7 +1,7 @@ use crate::{RunResult, TestRunError}; use core::fmt; use os_pipe::pipe; -use std::{fs::File, io::Read, path::Path, process::Command}; +use std::{fs::File, io::Read, process::Command}; #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq)] @@ -18,32 +18,23 @@ pub enum CargoCommand<'a> { features: Option<&'a str>, mode: BuildMode, }, - Build { - example: &'a str, + BuildAll { target: &'a str, features: Option<&'a str>, mode: BuildMode, }, - Objcopy { - example: &'a str, - target: &'a str, - features: Option<&'a str>, - ihex: &'a str, - }, - Size { - example_paths: Vec<&'a Path>, - }, - Clean, + // Size { + // example_paths: Vec<&'a Path>, + // }, + // Clean, } impl<'a> CargoCommand<'a> { fn name(&self) -> &str { match self { CargoCommand::Run { .. } => "run", - CargoCommand::Size { example_paths: _ } => "rust-size", - CargoCommand::Clean => "clean", - CargoCommand::Build { .. } => "build", - CargoCommand::Objcopy { .. } => "objcopy", + // CargoCommand::Size { example_paths: _ } => "rust-size", + CargoCommand::BuildAll { .. } => "build", } } @@ -54,12 +45,6 @@ impl<'a> CargoCommand<'a> { target, features, mode, - } - | CargoCommand::Build { - example, - target, - features, - mode, } => { let mut args = vec![self.name(), "--example", example, "--target", target]; @@ -71,26 +56,23 @@ impl<'a> CargoCommand<'a> { } args } - CargoCommand::Size { example_paths } => { - example_paths.iter().map(|p| p.to_str().unwrap()).collect() - } - CargoCommand::Clean => vec!["clean"], - CargoCommand::Objcopy { - example, + CargoCommand::BuildAll { target, features, - ihex, + mode, } => { - let mut args = vec![self.name(), "--example", example, "--target", target]; + let mut args = vec![self.name(), "--examples", "--target", target]; if let Some(feature_name) = features { args.extend_from_slice(&["--features", feature_name]); } - - // this always needs to go at the end - args.extend_from_slice(&["--", "-O", "ihex", ihex]); + if let Some(flag) = mode.to_flag() { + args.push(flag); + } args - } + } // CargoCommand::Size { example_paths } => { + // example_paths.iter().map(|p| p.to_str().unwrap()).collect() + // } } } @@ -99,7 +81,7 @@ impl<'a> CargoCommand<'a> { // we need to cheat a little here: // `cargo size` can't be ran on multiple files, so we're using `rust-size` instead – // which isn't a command that starts wizh `cargo`. So we're sneakily swapping them out :) - CargoCommand::Size { .. } => "rust-size", + // CargoCommand::Size { .. } => "rust-size", _ => "cargo", } } |
