From c4904b78ed977d1a068f532958f56bedd4ec3e22 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 31 Oct 2022 10:54:24 +0100 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=F0=9F=8E=A8=20Rename=20toolcha?= =?UTF-8?q?in=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.rs | 2 +- src/main.rs | 6 +++--- src/toolchain/espidf.rs | 2 +- src/toolchain/{gcc_toolchain.rs => gcc.rs} | 0 src/toolchain/{llvm_toolchain.rs => llvm.rs} | 0 src/toolchain/mod.rs | 6 +++--- src/toolchain/{rust_toolchain.rs => rust.rs} | 0 7 files changed, 8 insertions(+), 8 deletions(-) rename src/toolchain/{gcc_toolchain.rs => gcc.rs} (100%) rename src/toolchain/{llvm_toolchain.rs => llvm.rs} (100%) rename src/toolchain/{rust_toolchain.rs => rust.rs} (100%) diff --git a/src/config.rs b/src/config.rs index 639ba743..620138e0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -use crate::{host_triple::HostTriple, targets::Target, toolchain::rust_toolchain::XtensaRust}; +use crate::{host_triple::HostTriple, targets::Target, toolchain::rust::XtensaRust}; use directories_next::ProjectDirs; use miette::{ErrReport, IntoDiagnostic, Result, WrapErr}; use serde::{Deserialize, Serialize}; diff --git a/src/main.rs b/src/main.rs index 4edc5a92..227d1cd7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,9 +15,9 @@ use espup::{ espidf::{ get_dist_path, get_install_path, get_tool_path, EspIdfRepo, DEFAULT_GIT_REPOSITORY, }, - gcc_toolchain::{get_toolchain_name, install_gcc_targets}, - llvm_toolchain::LlvmToolchain, - rust_toolchain::{check_rust_installation, install_riscv_target, RustCrate, XtensaRust}, + gcc::{get_toolchain_name, install_gcc_targets}, + llvm::LlvmToolchain, + rust::{check_rust_installation, install_riscv_target, RustCrate, XtensaRust}, }, }; use log::{debug, info, warn}; diff --git a/src/toolchain/espidf.rs b/src/toolchain/espidf.rs index 7302d963..1d7b7541 100644 --- a/src/toolchain/espidf.rs +++ b/src/toolchain/espidf.rs @@ -4,7 +4,7 @@ use crate::{ emoji, targets::Target, toolchain::{ - gcc_toolchain::{get_toolchain_name, get_ulp_toolchain_name}, + gcc::{get_toolchain_name, get_ulp_toolchain_name}, get_home_dir, }, }; diff --git a/src/toolchain/gcc_toolchain.rs b/src/toolchain/gcc.rs similarity index 100% rename from src/toolchain/gcc_toolchain.rs rename to src/toolchain/gcc.rs diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm.rs similarity index 100% rename from src/toolchain/llvm_toolchain.rs rename to src/toolchain/llvm.rs diff --git a/src/toolchain/mod.rs b/src/toolchain/mod.rs index d144ed6b..fc1e0040 100644 --- a/src/toolchain/mod.rs +++ b/src/toolchain/mod.rs @@ -12,9 +12,9 @@ use tar::Archive; use xz2::read::XzDecoder; pub mod espidf; -pub mod gcc_toolchain; -pub mod llvm_toolchain; -pub mod rust_toolchain; +pub mod gcc; +pub mod llvm; +pub mod rust; /// Returns the path to the home directory. pub fn get_home_dir() -> String { diff --git a/src/toolchain/rust_toolchain.rs b/src/toolchain/rust.rs similarity index 100% rename from src/toolchain/rust_toolchain.rs rename to src/toolchain/rust.rs From cf2e364b6b58510ae7af9153066656aa83219809 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 31 Oct 2022 10:56:18 +0100 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=F0=9F=8E=A8=20Rename=20toolcha?= =?UTF-8?q?in=20structs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 11 +++++------ src/toolchain/gcc.rs | 6 +++--- src/toolchain/llvm.rs | 4 ++-- src/toolchain/rust.rs | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 227d1cd7..9c6caee9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,8 @@ use espup::{ get_dist_path, get_install_path, get_tool_path, EspIdfRepo, DEFAULT_GIT_REPOSITORY, }, gcc::{get_toolchain_name, install_gcc_targets}, - llvm::LlvmToolchain, - rust::{check_rust_installation, install_riscv_target, RustCrate, XtensaRust}, + llvm::Llvm, + rust::{check_rust_installation, install_riscv_target, Crate, XtensaRust}, }, }; use log::{debug, info, warn}; @@ -145,8 +145,7 @@ fn install(args: InstallOpts) -> Result<()> { info!("{} Installing esp-rs", emoji::DISC); let targets: HashSet = parse_targets(&args.targets).unwrap(); let host_triple = get_host_triple(args.default_host)?; - let mut extra_crates: HashSet = - args.extra_crates.split(',').map(RustCrate::new).collect(); + let mut extra_crates: HashSet = args.extra_crates.split(',').map(Crate::new).collect(); let mut exports: Vec = Vec::new(); let export_file = args.export_file.clone(); let xtensa_rust = if targets.contains(&Target::ESP32) @@ -157,7 +156,7 @@ fn install(args: InstallOpts) -> Result<()> { } else { None }; - let llvm = LlvmToolchain::new(args.llvm_version, args.profile_minimal, &host_triple); + let llvm = Llvm::new(args.llvm_version, args.profile_minimal, &host_triple); debug!( "{} Arguments: @@ -202,7 +201,7 @@ fn install(args: InstallOpts) -> Result<()> { if let Some(espidf_version) = &args.espidf_version { let repo = EspIdfRepo::new(espidf_version, args.profile_minimal, &targets); exports.extend(repo.install()?); - extra_crates.insert(RustCrate::new("ldproxy")); + extra_crates.insert(Crate::new("ldproxy")); } else { exports.extend(install_gcc_targets(&targets, &host_triple)?); } diff --git a/src/toolchain/gcc.rs b/src/toolchain/gcc.rs index 507702bd..16378514 100644 --- a/src/toolchain/gcc.rs +++ b/src/toolchain/gcc.rs @@ -19,7 +19,7 @@ const DEFAULT_GCC_RELEASE: &str = "esp-2021r2-patch5"; const DEFAULT_GCC_VERSION: &str = "8_4_0"; #[derive(Debug, Clone)] -pub struct GccToolchain { +pub struct Gcc { /// Host triple. pub host_triple: HostTriple, /// Repository release version to use. @@ -32,7 +32,7 @@ pub struct GccToolchain { pub version: String, } -impl GccToolchain { +impl Gcc { /// Gets the binary path. pub fn get_bin_path(&self) -> String { let toolchain_path = format!( @@ -144,7 +144,7 @@ pub fn install_gcc_targets( info!("{} Installing gcc for build targets", emoji::WRENCH); let mut exports: Vec = Vec::new(); for target in targets { - let gcc = GccToolchain::new(target, host_triple); + let gcc = Gcc::new(target, host_triple); gcc.install()?; #[cfg(windows)] diff --git a/src/toolchain/llvm.rs b/src/toolchain/llvm.rs index 769d1af4..ff933850 100644 --- a/src/toolchain/llvm.rs +++ b/src/toolchain/llvm.rs @@ -13,7 +13,7 @@ const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014"; #[derive(Debug, Clone, Default)] -pub struct LlvmToolchain { +pub struct Llvm { /// LLVM Toolchain file name. pub file_name: String, /// Host triple. @@ -26,7 +26,7 @@ pub struct LlvmToolchain { pub version: String, } -impl LlvmToolchain { +impl Llvm { /// Gets the name of the LLVM arch based on the host triple. fn get_arch(host_triple: &HostTriple) -> Result<&str> { match host_triple { diff --git a/src/toolchain/rust.rs b/src/toolchain/rust.rs index 314b0801..deaece16 100644 --- a/src/toolchain/rust.rs +++ b/src/toolchain/rust.rs @@ -157,12 +157,12 @@ impl XtensaRust { } #[derive(Hash, Eq, PartialEq, Debug, Clone, Serialize, Deserialize, Default)] -pub struct RustCrate { +pub struct Crate { /// Crate name. pub name: String, } -impl RustCrate { +impl Crate { /// Installs a crate. pub fn install(&self) -> Result<()> { #[cfg(unix)] @@ -180,7 +180,7 @@ impl RustCrate { /// Create a crate instance. pub fn new(name: &str) -> Self { - RustCrate { + Crate { name: name.to_string(), } }