diff --git a/src/toolchain/llvm.rs b/src/toolchain/llvm.rs index a3eb2d8..c51247a 100644 --- a/src/toolchain/llvm.rs +++ b/src/toolchain/llvm.rs @@ -10,7 +10,10 @@ use crate::{ use async_trait::async_trait; use log::{info, warn}; use miette::Result; -use std::path::{Path, PathBuf}; +use std::{ + fs::remove_dir_all, + path::{Path, PathBuf}, +}; const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221201"; @@ -78,6 +81,14 @@ impl Llvm { version, } } + + /// Uninstall LLVM toolchain. + pub fn uninstall(llvm_path: &Path) -> Result<(), Error> { + info!("{} Deleting Xtensa LLVM", emoji::WRENCH); + remove_dir_all(llvm_path) + .map_err(|_| Error::FailedToRemoveDirectory(llvm_path.display().to_string()))?; + Ok(()) + } } #[async_trait]