diff options
author | 2021-09-20 17:35:15 +0200 | |
---|---|---|
committer | 2021-09-20 18:46:15 +0200 | |
commit | 7f45254e3939af5aa940c65e52c63fa83b93c16d (patch) | |
tree | a958fa60fbeafedb7d8578c47fcaf506722e316f | |
parent | 7ce4391e4e6bce03d42962266fe0587922e13571 (diff) | |
download | rtic-7f45254e3939af5aa940c65e52c63fa83b93c16d.tar.gz rtic-7f45254e3939af5aa940c65e52c63fa83b93c16d.tar.zst rtic-7f45254e3939af5aa940c65e52c63fa83b93c16d.zip |
start with a clean ci/builds always
-rw-r--r-- | xtask/src/build.rs | 26 | ||||
-rw-r--r-- | xtask/src/main.rs | 4 |
2 files changed, 24 insertions, 6 deletions
diff --git a/xtask/src/build.rs b/xtask/src/build.rs index 11666ad4..a8c19aac 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -1,7 +1,22 @@ -use std::path::PathBuf; +use std::{ + fs, + path::{Path, PathBuf}, +}; use crate::{command::BuildMode, TestRunError}; +const HEX_BUILD_ROOT: &str = "ci/builds"; + +/// make sure we're starting with a clean,but existing slate +pub fn init_build_dir() -> anyhow::Result<()> { + if Path::new(HEX_BUILD_ROOT).exists() { + fs::remove_dir_all(HEX_BUILD_ROOT) + .map_err(|_| anyhow::anyhow!("Could not clear out directory: {}", HEX_BUILD_ROOT))?; + } + fs::create_dir_all(HEX_BUILD_ROOT) + .map_err(|_| anyhow::anyhow!("Could not create directory: {}", HEX_BUILD_ROOT)) +} + pub fn build_hexpath( example: &str, features: Option<&str>, @@ -14,10 +29,11 @@ pub fn build_hexpath( }; let filename = format!("{}_{}_{}_{}.hex", example, features, build_mode, build_num); - ["ci", "builds", &filename] - .iter() - .collect::<PathBuf>() - .into_os_string() + + let mut path = PathBuf::from(HEX_BUILD_ROOT); + path.push(filename); + + path.into_os_string() .into_string() .map_err(|e| anyhow::Error::new(TestRunError::PathConversionError(e))) } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 4d582ddd..3243b98e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -14,7 +14,7 @@ use std::{ use structopt::StructOpt; use crate::{ - build::{build_hexpath, compare_builds}, + build::{build_hexpath, compare_builds, init_build_dir}, command::{run_command, run_successful, BuildMode, CargoCommand}, }; @@ -98,6 +98,8 @@ fn main() -> anyhow::Result<()> { let opts = Options::from_args(); let target = &opts.target; + init_build_dir()?; + if target == "all" { for t in targets { run_test(t, examples)?; |