diff options
| author | Lotte Steenbrink <lotte.steenbrink@ferrous-systems.com> | 2021-09-20 17:35:15 +0200 |
|---|---|---|
| committer | Lotte Steenbrink <lotte.steenbrink@ferrous-systems.com> | 2021-09-20 18:46:15 +0200 |
| commit | 7f45254e3939af5aa940c65e52c63fa83b93c16d (patch) | |
| tree | a958fa60fbeafedb7d8578c47fcaf506722e316f /xtask/src/build.rs | |
| parent | 7ce4391e4e6bce03d42962266fe0587922e13571 (diff) | |
start with a clean ci/builds always
Diffstat (limited to 'xtask/src/build.rs')
| -rw-r--r-- | xtask/src/build.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/xtask/src/build.rs b/xtask/src/build.rs index 11666ad..a8c19aa 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))) } |
