style: 🎨 Format includes

This commit is contained in:
Sergio Gasquez 2022-09-23 12:08:59 +02:00
parent 99c5a154a1
commit 517cce3ac1
3 changed files with 21 additions and 23 deletions

View File

@ -5,14 +5,15 @@ use crate::emoji;
use crate::gcc_toolchain::{get_toolchain_name, get_ulp_toolchain_name};
use crate::utils::get_home_dir;
use anyhow::{Context, Result};
use embuild::espidf::EspIdfRemote;
use embuild::{espidf, git};
use embuild::{espidf, espidf::EspIdfRemote, git};
use log::{debug, info};
use std::collections::hash_map::DefaultHasher;
use std::env;
use std::fs;
use std::hash::{Hash, Hasher};
use std::path::PathBuf;
use std::{
collections::hash_map::DefaultHasher,
env,
fs::remove_dir_all,
hash::{Hash, Hasher},
path::PathBuf,
};
use strum::{Display, EnumIter, EnumString, IntoStaticStr};
const DEFAULT_GIT_REPOSITORY: &str = "https://github.com/espressif/esp-idf";
@ -139,10 +140,10 @@ impl EspIdfRepo {
exports.push(format!("export PATH={:?}", espidf.exported_path));
if self.minified {
info!("{} Minifying ESP-IDF", emoji::INFO);
fs::remove_dir_all(espidf_dir.join("docs"))?;
fs::remove_dir_all(espidf_dir.join("examples"))?;
fs::remove_dir_all(espidf_dir.join("tools").join("esp_app_trace"))?;
fs::remove_dir_all(espidf_dir.join("tools").join("test_idf_size"))?;
remove_dir_all(espidf_dir.join("docs"))?;
remove_dir_all(espidf_dir.join("examples"))?;
remove_dir_all(espidf_dir.join("tools").join("esp_app_trace"))?;
remove_dir_all(espidf_dir.join("tools").join("test_idf_size"))?;
}
Ok(exports)

View File

@ -8,9 +8,7 @@ use crate::utils::{download_file, get_home_dir};
use anyhow::{bail, Result};
use embuild::cmd;
use log::{info, warn};
use std::env;
use std::path::PathBuf;
use std::process::Stdio;
use std::{env, path::PathBuf, process::Stdio};
const DEFAULT_XTENSA_RUST_REPOSITORY: &str =
"https://github.com/esp-rs/rust-build/releases/download";

View File

@ -5,12 +5,11 @@ use anyhow::{bail, Result};
use dirs::home_dir;
use flate2::bufread::GzDecoder;
use log::{debug, info};
use std::fs::File;
use std::io::BufReader;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::{fs, io};
use std::{
fs::{create_dir_all, remove_dir_all, File},
io::{copy, BufReader, Write},
path::{Path, PathBuf},
};
use tar::Archive;
use xz2::read::XzDecoder;
@ -30,7 +29,7 @@ pub mod logging {
/// Deletes dist folder.
pub fn clear_dist_folder() -> Result<()> {
info!("{} Clearing dist folder", emoji::WRENCH);
fs::remove_dir_all(&get_dist_path(""))?;
remove_dir_all(&get_dist_path(""))?;
Ok(())
}
@ -83,7 +82,7 @@ pub fn download_file(
return Ok(file_path);
} else if !Path::new(&output_directory).exists() {
info!("{} Creating directory: {}", emoji::WRENCH, output_directory);
if let Err(_e) = fs::create_dir_all(output_directory) {
if let Err(_e) = create_dir_all(output_directory) {
bail!(
"{} Creating directory {} failed",
emoji::ERROR,
@ -137,7 +136,7 @@ pub fn download_file(
} else {
info!("{} Creating file: {}", emoji::WRENCH, file_path);
let mut out = File::create(file_path)?;
io::copy(&mut resp, &mut out)?;
copy(&mut resp, &mut out)?;
}
Ok(format!("{}/{}", output_directory, file_name))
}