refactor: ♻️ Add uninstall methods

This commit is contained in:
Sergio Gasquez 2022-12-27 10:20:56 +01:00
parent abf4d4d7c0
commit 8f2ce52020

View File

@ -12,7 +12,10 @@ use async_trait::async_trait;
use embuild::espidf::EspIdfVersion;
use log::{debug, warn};
use miette::Result;
use std::path::{Path, PathBuf};
use std::{
fs::remove_dir_all,
path::{Path, PathBuf},
};
const DEFAULT_GCC_REPOSITORY: &str = "https://github.com/espressif/crosstool-NG/releases/download";
const DEFAULT_GCC_RELEASE: &str = "esp-2021r2-patch5";
@ -67,6 +70,19 @@ impl Gcc {
version: DEFAULT_GCC_VERSION.to_string(),
}
}
pub fn uninstall(target: &Target) -> Result<(), Error> {
let gcc_path = get_tool_path(&get_toolchain_name(target));
remove_dir_all(&gcc_path).map_err(|_| Error::FailedToRemoveDirectory(gcc_path))?;
Ok(())
}
pub fn uninstall_riscv() -> Result<(), Error> {
let riscv_gcc_path = get_tool_path(RISCV_GCC);
remove_dir_all(&riscv_gcc_path)
.map_err(|_| Error::FailedToRemoveDirectory(riscv_gcc_path))?;
Ok(())
}
}
#[async_trait]