mirror of
https://github.com/esp-rs/espup.git
synced 2025-10-02 15:14:56 +00:00
fix: 🐛 Fix riscv uninstallation
This commit is contained in:
parent
0ae42f5742
commit
1f8a04ec83
19
src/main.rs
19
src/main.rs
@ -18,7 +18,8 @@ use espup::{
|
|||||||
gcc::{get_toolchain_name, install_gcc_targets},
|
gcc::{get_toolchain_name, install_gcc_targets},
|
||||||
llvm::Llvm,
|
llvm::Llvm,
|
||||||
rust::{
|
rust::{
|
||||||
check_rust_installation, install_extra_crates, install_riscv_target, Crate, XtensaRust,
|
check_rust_installation, install_extra_crates, install_riscv_target,
|
||||||
|
uninstall_riscv_target, Crate, XtensaRust,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update::check_for_update,
|
update::check_for_update,
|
||||||
@ -189,7 +190,7 @@ fn install(args: InstallOpts) -> Result<()> {
|
|||||||
|
|
||||||
exports.extend(llvm.install()?);
|
exports.extend(llvm.install()?);
|
||||||
|
|
||||||
if targets.contains(&Target::ESP32C3) {
|
if targets.contains(&Target::ESP32C3) || targets.contains(&Target::ESP32C2) {
|
||||||
install_riscv_target(&args.nightly_version)?;
|
install_riscv_target(&args.nightly_version)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +274,11 @@ fn uninstall(args: UninstallOpts) -> Result<()> {
|
|||||||
.map_err(|_| Error::FailedToRemoveDirectory(llvm_path.display().to_string()))?;
|
.map_err(|_| Error::FailedToRemoveDirectory(llvm_path.display().to_string()))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.targets.contains(&Target::ESP32C3) || config.targets.contains(&Target::ESP32C2) {
|
||||||
|
info!("{} Deleting RISC-V target", emoji::WRENCH);
|
||||||
|
uninstall_riscv_target(&config.nightly_version)?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(esp_idf_version) = config.esp_idf_version {
|
if let Some(esp_idf_version) = config.esp_idf_version {
|
||||||
info!("{} Deleting ESP-IDF {}", emoji::WRENCH, esp_idf_version);
|
info!("{} Deleting ESP-IDF {}", emoji::WRENCH, esp_idf_version);
|
||||||
config.esp_idf_version = None;
|
config.esp_idf_version = None;
|
||||||
@ -293,6 +299,15 @@ fn uninstall(args: UninstallOpts) -> Result<()> {
|
|||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
info!("{} Deleting GCC targets", emoji::WRENCH);
|
info!("{} Deleting GCC targets", emoji::WRENCH);
|
||||||
|
if config.targets.contains(&Target::ESP32C3) || config.targets.contains(&Target::ESP32C2) {
|
||||||
|
config.targets.remove(&Target::ESP32C3);
|
||||||
|
config.targets.remove(&Target::ESP32C2);
|
||||||
|
config.save()?;
|
||||||
|
// All RiscV targets use the same GCC toolchain
|
||||||
|
let riscv_gcc_path = get_tool_path(&get_toolchain_name(&Target::ESP32C3));
|
||||||
|
remove_dir_all(&riscv_gcc_path)
|
||||||
|
.map_err(|_| Error::FailedToRemoveDirectory(riscv_gcc_path))?;
|
||||||
|
}
|
||||||
for target in &config.targets.clone() {
|
for target in &config.targets.clone() {
|
||||||
config.targets.remove(target);
|
config.targets.remove(target);
|
||||||
config.save()?;
|
config.save()?;
|
||||||
|
@ -409,6 +409,22 @@ fn install_rust_nightly(version: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unnstalls the RiscV target.
|
||||||
|
pub fn uninstall_riscv_target(nightly_version: &str) -> Result<()> {
|
||||||
|
info!("{} Installing Riscv target", emoji::WRENCH);
|
||||||
|
cmd!(
|
||||||
|
"rustup",
|
||||||
|
"target",
|
||||||
|
"remove",
|
||||||
|
"--toolchain",
|
||||||
|
nightly_version,
|
||||||
|
"riscv32imac-unknown-none-elf"
|
||||||
|
)
|
||||||
|
.run()
|
||||||
|
.into_diagnostic()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::toolchain::rust::{Crate, XtensaRust};
|
use crate::toolchain::rust::{Crate, XtensaRust};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user