mirror of
https://github.com/esp-rs/espup.git
synced 2025-09-28 05:10:44 +00:00
feat: ✨ Add support for clearing dist folder
This commit is contained in:
parent
a5cb819156
commit
3bb44c1d1f
12
src/main.rs
12
src/main.rs
@ -5,7 +5,7 @@ use crate::llvm_toolchain::LlvmToolchain;
|
||||
use crate::rust_toolchain::{
|
||||
check_rust_installation, get_rust_crate, install_crate, RustCrate, RustToolchain,
|
||||
};
|
||||
use crate::utils::{get_tools_path, parse_targets, print_arguments};
|
||||
use crate::utils::{clear_dist_folder, get_tools_path, parse_targets, print_arguments};
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
||||
@ -68,7 +68,7 @@ pub struct InstallOpts {
|
||||
#[clap(short = 'l', long, default_value = "14")]
|
||||
pub llvm_version: String,
|
||||
/// [Only applies if using -s|--esp-idf-version]. Deletes some esp-idf folders to save space.
|
||||
#[clap(short = 'm', long)]
|
||||
#[clap(short = 'm', long, takes_value = false)]
|
||||
pub minified_espidf: bool,
|
||||
/// Nightly Rust toolchain version.
|
||||
#[clap(short = 'n', long, default_value = "nightly")]
|
||||
@ -88,8 +88,8 @@ pub struct InstallOpts {
|
||||
#[clap(short = 't', long, default_value = "1.62.1.0")]
|
||||
pub toolchain_version: String,
|
||||
/// Removes cached distribution files.
|
||||
#[clap(short = 'x', long)]
|
||||
pub clear_cache: bool,
|
||||
#[clap(short = 'x', long, takes_value = false)]
|
||||
pub clear_dist: bool,
|
||||
/// Verbosity level of the logs.
|
||||
#[clap(flatten)]
|
||||
verbose: Verbosity<InfoLevel>,
|
||||
@ -156,7 +156,9 @@ fn install(args: InstallOpts) -> Result<()> {
|
||||
install_crate(extra_crate)?;
|
||||
}
|
||||
|
||||
// TODO: Clear cache
|
||||
if args.clear_dist {
|
||||
clear_dist_folder()?;
|
||||
}
|
||||
|
||||
info!("{} Updating environment variables:", emoji::DIAMOND);
|
||||
for e in exports.iter() {
|
||||
|
18
src/utils.rs
18
src/utils.rs
@ -13,6 +13,12 @@ use std::{fs, io};
|
||||
use tar::Archive;
|
||||
use xz2::read::XzDecoder;
|
||||
|
||||
pub fn clear_dist_folder() -> Result<()> {
|
||||
info!("{} Clearing dist folder", emoji::WRENCH);
|
||||
fs::remove_dir_all(&get_dist_path(""))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn parse_targets(build_target: &str) -> Result<Vec<Chip>, String> {
|
||||
debug!("{} Parsing targets: {}", emoji::DEBUG, build_target);
|
||||
let mut chips: Vec<Chip> = Vec::new();
|
||||
@ -131,21 +137,13 @@ pub fn download_file(
|
||||
Ok(format!("{}/{}", output_directory, file_name))
|
||||
}
|
||||
|
||||
// pub fn get_python_env_path(idf_version: &str, python_version: &str) -> String {
|
||||
// let tools_path = get_tools_path();
|
||||
// format!(
|
||||
// "{}/python_env/idf{}_py{}_env",
|
||||
// tools_path, idf_version, python_version
|
||||
// )
|
||||
// }
|
||||
|
||||
pub fn print_arguments(args: &InstallOpts, arch: &str, targets: &Vec<Chip>) {
|
||||
debug!(
|
||||
"{} Arguments:
|
||||
- Arch: {}
|
||||
- Build targets: {:?}
|
||||
- Cargo home: {:?}
|
||||
- Clear cache: {:?}
|
||||
- Clear dist folder: {:?}
|
||||
- ESP-IDF version: {:?}
|
||||
- Export file: {:?}
|
||||
- Extra crates: {:?}
|
||||
@ -159,7 +157,7 @@ pub fn print_arguments(args: &InstallOpts, arch: &str, targets: &Vec<Chip>) {
|
||||
arch,
|
||||
targets,
|
||||
&args.cargo_home,
|
||||
args.clear_cache,
|
||||
args.clear_dist,
|
||||
&args.espidf_version,
|
||||
&args.export_file,
|
||||
args.extra_crates,
|
||||
|
Loading…
x
Reference in New Issue
Block a user