From f25545e0f37e5dff376cf52a116a3dfede259135 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 27 Dec 2022 10:21:25 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20Add=20uninstal?= =?UTF-8?q?l=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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]