From 449eaec33894e6df5bf1bcf353296d5d1c6f45e7 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 17 Oct 2022 14:49:51 +0000 Subject: [PATCH 01/15] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20llvm-version=20?= =?UTF-8?q?arg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 7 ++-- src/toolchain/llvm_toolchain.rs | 63 +++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1d8dfbf..b9b032e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,6 +80,9 @@ pub struct InstallOpts { // Make it vector and have splliter =" " #[arg(short = 'c', long, default_value = "cargo-espflash")] pub extra_crates: String, + /// LLVM version. + #[arg(short = 'x', long, default_value = "14", value_parser = ["14", "15"])] + pub llvm_version: String, /// Verbosity level of the logs. #[arg(short = 'l', long, default_value = "info", value_parser = ["debug", "info", "warn", "error"])] pub log_level: String, @@ -148,9 +151,9 @@ fn install(args: InstallOpts) -> Result<()> { // Complete LLVM is failing for Windows, aarch64 MacOs, and aarch64 Linux, so we are using always minified. #[cfg(all(target_arch = "x86_64", target_os = "linux"))] - let llvm = LlvmToolchain::new(args.profile_minimal, &host_triple); + let llvm = LlvmToolchain::new(args.llvm_version, args.profile_minimal, &host_triple); #[cfg(any(not(target_arch = "x86_64"), not(target_os = "linux")))] - let llvm = LlvmToolchain::new(true, &host_triple); + let llvm = LlvmToolchain::new(args.llvm_version, true, &host_triple); debug!( "{} Arguments: diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index 80953ac..ecbf684 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -9,11 +9,16 @@ use anyhow::{bail, Ok, Result}; use log::info; use std::path::{Path, PathBuf}; -const DEFAULT_LLVM_COMPLETE_REPOSITORY: &str = +// LLVM 14 +const DEFAULT_LLVM_14_COMPLETE_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; -const DEFAULT_LLVM_MINIFIED_REPOSITORY: &str = +const DEFAULT_LLVM_14_MINIFIED_REPOSITORY: &str = "https://github.com/esp-rs/rust-build/releases/download/llvm-project-14.0-minified"; -const DEFAULT_LLVM_VERSION: &str = "esp-14.0.0-20220415"; +const DEFAULT_LLVM_14_VERSION: &str = "esp-14.0.0-20220415"; +// LLVM 15 +const DEFAULT_LLVM_15_REPOSITORY: &str = + "https://github.com/espressif/llvm-project/releases/download"; +const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20220922"; #[derive(Debug)] pub struct LlvmToolchain { @@ -25,8 +30,6 @@ pub struct LlvmToolchain { pub path: PathBuf, /// The repository containing LVVM sources. pub repository_url: String, - /// Repository release version to use. - pub version: String, } impl LlvmToolchain { @@ -98,32 +101,49 @@ impl LlvmToolchain { } /// Create a new instance with default values and proper toolchain version. - pub fn new(minified: bool, host_triple: &HostTriple) -> Self { - let file_name: String; - let version = DEFAULT_LLVM_VERSION.to_string(); + pub fn new(version: String, minified: bool, host_triple: &HostTriple) -> Self { + let mut file_name: String; let repository_url: String; - if minified { - file_name = format!( - "xtensa-esp32-elf-llvm{}-{}-{}.{}", - get_release_with_underscores(&version), - &version, - host_triple, - Self::get_artifact_extension(host_triple) - ); - repository_url = format!("{}/{}", DEFAULT_LLVM_MINIFIED_REPOSITORY, file_name,); + if version == "14" { + if minified { + file_name = format!( + "xtensa-esp32-elf-llvm{}-{}-{}.{}", + get_release_with_underscores(DEFAULT_LLVM_14_VERSION), + DEFAULT_LLVM_14_VERSION, + host_triple, + Self::get_artifact_extension(host_triple) + ); + repository_url = format!("{}/{}", DEFAULT_LLVM_14_MINIFIED_REPOSITORY, file_name,); + } else { + file_name = format!( + "xtensa-esp32-elf-llvm{}-{}-{}.{}", + get_release_with_underscores(DEFAULT_LLVM_14_VERSION), + DEFAULT_LLVM_14_VERSION, + Self::get_arch(host_triple).unwrap(), + Self::get_artifact_extension(host_triple) + ); + repository_url = format!( + "{}/{}/{}", + DEFAULT_LLVM_14_COMPLETE_REPOSITORY, DEFAULT_LLVM_14_VERSION, file_name + ); + } } else { + // version == "15" file_name = format!( - "xtensa-esp32-elf-llvm{}-{}-{}.{}", - get_release_with_underscores(&version), - &version, + "llvm-{}-{}.{}", + DEFAULT_LLVM_15_VERSION, Self::get_arch(host_triple).unwrap(), Self::get_artifact_extension(host_triple) ); + if minified { + file_name = format!("libs_{}", file_name); + } repository_url = format!( "{}/{}/{}", - DEFAULT_LLVM_COMPLETE_REPOSITORY, &version, file_name + DEFAULT_LLVM_15_REPOSITORY, DEFAULT_LLVM_15_VERSION, file_name, ); } + let path = format!( "{}/{}-{}", get_tool_path("xtensa-esp32-elf-clang"), @@ -136,7 +156,6 @@ impl LlvmToolchain { host_triple: host_triple.clone(), path, repository_url, - version, } } } From 4174e351195a3a099e6d06afc5ecd4ce40bb4976 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 18 Oct 2022 11:31:02 +0000 Subject: [PATCH 02/15] =?UTF-8?q?feat:=20=E2=9C=A8=20Support=20new=20llvm?= =?UTF-8?q?=20targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index ecbf684..fa20a89 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -34,16 +34,27 @@ pub struct LlvmToolchain { impl LlvmToolchain { /// Gets the name of the LLVM arch based on the host triple. - fn get_arch(host_triple: &HostTriple) -> Result<&str> { - match host_triple { - HostTriple::Aarch64AppleDarwin | HostTriple::X86_64AppleDarwin => Ok("macos"), - HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), - HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), - _ => bail!( - "{} No LLVM arch found for the host triple: '{}'", - emoji::ERROR, - host_triple - ), + fn get_arch<'a>(version: &'a str, host_triple: &'a HostTriple) -> Result<&'a str> { + if version == "14" { + match host_triple { + HostTriple::Aarch64AppleDarwin | HostTriple::X86_64AppleDarwin => Ok("macos"), + HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), + HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), + _ => bail!( + "{} No LLVM arch found for the host triple: '{}'", + emoji::ERROR, + host_triple + ), + } + } else { + // LLVM 15 + match host_triple { + HostTriple::Aarch64AppleDarwin => Ok("macos-arm64"), + HostTriple::X86_64AppleDarwin => Ok("macos"), + HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), + HostTriple::Aarch64UnknownLinuxGnu => Ok("linux-arm64"), + HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), + } } } @@ -119,7 +130,7 @@ impl LlvmToolchain { "xtensa-esp32-elf-llvm{}-{}-{}.{}", get_release_with_underscores(DEFAULT_LLVM_14_VERSION), DEFAULT_LLVM_14_VERSION, - Self::get_arch(host_triple).unwrap(), + Self::get_arch(&version, host_triple).unwrap(), Self::get_artifact_extension(host_triple) ); repository_url = format!( @@ -132,7 +143,7 @@ impl LlvmToolchain { file_name = format!( "llvm-{}-{}.{}", DEFAULT_LLVM_15_VERSION, - Self::get_arch(host_triple).unwrap(), + Self::get_arch(&version, host_triple).unwrap(), Self::get_artifact_extension(host_triple) ); if minified { From 535b43a5982bf58b4bfc873d41ee0b874fedbd8d Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Wed, 19 Oct 2022 12:04:29 +0000 Subject: [PATCH 03/15] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20LIBCLANG=5FPA?= =?UTF-8?q?TH=20for=20LLVM=2015?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 36 ++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index fa20a89..5f29dcd 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -30,6 +30,8 @@ pub struct LlvmToolchain { pub path: PathBuf, /// The repository containing LVVM sources. pub repository_url: String, + /// LLVM Version ["14", "15"]. + pub version: String, } impl LlvmToolchain { @@ -69,10 +71,17 @@ impl LlvmToolchain { /// Gets the binary path. fn get_lib_path(&self) -> String { #[cfg(windows)] - let llvm_path = format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap()); + if self.version == "14" { + llvm_path = format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap()) + } else { + llvm_path = format!("{}/esp-clang/lib", self.path.to_str().unwrap()) + } #[cfg(unix)] - let llvm_path = format!("{}/xtensa-esp32-elf-clang/lib", self.path.to_str().unwrap()); - llvm_path + if self.version == "14" { + format!("{}/xtensa-esp32-elf-clang/lib", self.path.to_str().unwrap()) + } else { + format!("{}/esp-clang/lib", self.path.to_str().unwrap()) + } } /// Installs the LLVM toolchain. @@ -115,6 +124,7 @@ impl LlvmToolchain { pub fn new(version: String, minified: bool, host_triple: &HostTriple) -> Self { let mut file_name: String; let repository_url: String; + let path: PathBuf; if version == "14" { if minified { file_name = format!( @@ -138,6 +148,12 @@ impl LlvmToolchain { DEFAULT_LLVM_14_COMPLETE_REPOSITORY, DEFAULT_LLVM_14_VERSION, file_name ); } + path = PathBuf::from(format!( + "{}/{}-{}", + get_tool_path("xtensa-esp32-elf-clang"), + DEFAULT_LLVM_14_VERSION, + host_triple + )); } else { // version == "15" file_name = format!( @@ -153,20 +169,20 @@ impl LlvmToolchain { "{}/{}/{}", DEFAULT_LLVM_15_REPOSITORY, DEFAULT_LLVM_15_VERSION, file_name, ); + path = PathBuf::from(format!( + "{}/{}-{}", + get_tool_path("xtensa-esp32-elf-clang"), + DEFAULT_LLVM_15_VERSION, + host_triple + )); } - let path = format!( - "{}/{}-{}", - get_tool_path("xtensa-esp32-elf-clang"), - version, - host_triple - ) - .into(); Self { file_name, host_triple: host_triple.clone(), path, repository_url, + version, } } } From 0e06b1bf1cf79a6c4e652b0dffdcc5907fe5352b Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Wed, 19 Oct 2022 14:09:20 +0200 Subject: [PATCH 04/15] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20windows=20com?= =?UTF-8?q?pilation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index 5f29dcd..ac9d0e0 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -72,9 +72,9 @@ impl LlvmToolchain { fn get_lib_path(&self) -> String { #[cfg(windows)] if self.version == "14" { - llvm_path = format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap()) + format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap()) } else { - llvm_path = format!("{}/esp-clang/lib", self.path.to_str().unwrap()) + format!("{}/esp-clang/lib", self.path.to_str().unwrap()) } #[cfg(unix)] if self.version == "14" { From a62b98e6519b2d1f295740062e0bdc9d8ff6b816 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 09:33:29 +0000 Subject: [PATCH 05/15] =?UTF-8?q?refactor:=20=F0=9F=8E=A8=20Update=20forma?= =?UTF-8?q?t=20for=20llvm=2015?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index ac9d0e0..3f4b89a 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -18,7 +18,7 @@ const DEFAULT_LLVM_14_VERSION: &str = "esp-14.0.0-20220415"; // LLVM 15 const DEFAULT_LLVM_15_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; -const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20220922"; +const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014"; #[derive(Debug)] pub struct LlvmToolchain { @@ -157,10 +157,9 @@ impl LlvmToolchain { } else { // version == "15" file_name = format!( - "llvm-{}-{}.{}", + "llvm-{}-{}.tar.xz", DEFAULT_LLVM_15_VERSION, - Self::get_arch(&version, host_triple).unwrap(), - Self::get_artifact_extension(host_triple) + Self::get_arch(&version, host_triple).unwrap() ); if minified { file_name = format!("libs_{}", file_name); From d3a2496b4e70f104bd749d5bc62b46cc7f1b9f7c Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 09:33:48 +0000 Subject: [PATCH 06/15] =?UTF-8?q?build:=20=E2=9E=95=20Add=20libtinfo5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8af5956..eb0c35c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,7 +10,7 @@ ARG CONTAINER_GROUP=esp # Install dependencies RUN apt-get update \ - && apt-get install -y git curl gcc clang ninja-build libudev-dev unzip xz-utils\ + && apt-get install -y git curl gcc clang ninja-build libudev-dev unzip xz-utils libtinfo5\ python3 python3-pip python3-venv libusb-1.0-0 libssl-dev pkg-config libtinfo5 libpython2.7 \ && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts From c0aa846fac9bbda7626a82504b9a5d6a418b94ef Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 09:34:44 +0000 Subject: [PATCH 07/15] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Add=20libtinfo5=20?= =?UTF-8?q?dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 398e1e7..344ca62 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ developing applications in Rust for Espressif SoC's. ### Linux - Ubuntu/Debian ```sh -apt-get install -y git python3 python3-pip gcc build-essential curl pkg-config libudev-dev libssl-dev +apt-get install -y git python3 python3-pip gcc build-essential curl pkg-config libudev-dev libssl-dev libtinfo5 ``` - Fedora ```sh From 010a1ca4f8241fd5cfc662c4a0f3fabc745c9f4d Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 10:07:25 +0000 Subject: [PATCH 08/15] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Add=20libtinfo5=20?= =?UTF-8?q?dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 344ca62..4d2adce 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ apt-get install -y git python3 python3-pip gcc build-essential curl pkg-config l ``` - Fedora ```sh -dnf -y install git python3 python3-pip gcc openssl1.1 systemd-devel +dnf -y install git python3 python3-pip gcc openssl1.1 systemd-devel ncurses-compat-libs ``` ## Installation From 51a8f10f03c1128a0808f9f5872e35b2f05c6d5f Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 14:20:16 +0200 Subject: [PATCH 09/15] =?UTF-8?q?feat:=20=F0=9F=94=A5=20Remove=20llvm=2014?= =?UTF-8?q?=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 7 +- src/toolchain/llvm_toolchain.rs | 153 ++++++-------------------------- 2 files changed, 30 insertions(+), 130 deletions(-) diff --git a/src/main.rs b/src/main.rs index a17e3ec..21905b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,7 +81,7 @@ pub struct InstallOpts { #[arg(short = 'c', long, default_value = "cargo-espflash")] pub extra_crates: String, /// LLVM version. - #[arg(short = 'x', long, default_value = "14", value_parser = ["14", "15"])] + #[arg(short = 'x', long, default_value = "15", value_parser = ["15"])] pub llvm_version: String, /// Verbosity level of the logs. #[arg(short = 'l', long, default_value = "info", value_parser = ["debug", "info", "warn", "error"])] @@ -148,12 +148,7 @@ fn install(args: InstallOpts) -> Result<()> { let mut exports: Vec = Vec::new(); let export_file = args.export_file.clone(); let rust_toolchain = RustToolchain::new(&args.toolchain_version, &host_triple); - - // Complete LLVM is failing for Windows, aarch64 MacOs, and aarch64 Linux, so we are using always minified. - #[cfg(all(target_arch = "x86_64", target_os = "linux"))] let llvm = LlvmToolchain::new(args.llvm_version, args.profile_minimal, &host_triple); - #[cfg(any(not(target_arch = "x86_64"), not(target_os = "linux")))] - let llvm = LlvmToolchain::new(args.llvm_version, true, &host_triple); debug!( "{} Arguments: diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index 6b3ccaf..f37b151 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -9,14 +9,7 @@ use anyhow::{bail, Ok, Result}; use log::{info, warn}; use std::path::{Path, PathBuf}; -// LLVM 14 -const DEFAULT_LLVM_14_COMPLETE_REPOSITORY: &str = - "https://github.com/espressif/llvm-project/releases/download"; -const DEFAULT_LLVM_14_MINIFIED_REPOSITORY: &str = - "https://github.com/esp-rs/rust-build/releases/download/llvm-project-14.0-minified"; -const DEFAULT_LLVM_14_VERSION: &str = "esp-14.0.0-20220415"; -// LLVM 15 -const DEFAULT_LLVM_15_REPOSITORY: &str = +const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014"; @@ -28,60 +21,31 @@ pub struct LlvmToolchain { pub host_triple: HostTriple, /// LLVM Toolchain path. pub path: PathBuf, - /// The repository containing LVVM sources. + /// The repository containing LLVM sources. pub repository_url: String, - /// LLVM Version ["14", "15"]. + /// LLVM Version ["15"]. pub version: String, } impl LlvmToolchain { /// Gets the name of the LLVM arch based on the host triple. fn get_arch<'a>(version: &'a str, host_triple: &'a HostTriple) -> Result<&'a str> { - if version == "14" { - match host_triple { - HostTriple::Aarch64AppleDarwin | HostTriple::X86_64AppleDarwin => Ok("macos"), - HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), - HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), - _ => bail!( - "{} No LLVM arch found for the host triple: '{}'", - emoji::ERROR, - host_triple - ), - } - } else { - // LLVM 15 - match host_triple { - HostTriple::Aarch64AppleDarwin => Ok("macos-arm64"), - HostTriple::X86_64AppleDarwin => Ok("macos"), - HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), - HostTriple::Aarch64UnknownLinuxGnu => Ok("linux-arm64"), - HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), - } - } - } - - /// Gets the artifact extension based on the host triple. - fn get_artifact_extension(host_triple: &HostTriple) -> &str { match host_triple { - HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => "zip", - _ => "tar.xz", + HostTriple::Aarch64AppleDarwin => Ok("macos-arm64"), + HostTriple::X86_64AppleDarwin => Ok("macos"), + HostTriple::X86_64UnknownLinuxGnu => Ok("linux-amd64"), + HostTriple::Aarch64UnknownLinuxGnu => Ok("linux-arm64"), + HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => Ok("win64"), } } /// Gets the binary path. fn get_lib_path(&self) -> String { #[cfg(windows)] - if self.version == "14" { - format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap()) - } else { - format!("{}/esp-clang/lib", self.path.to_str().unwrap()) - } + format!("{}/esp-clang/bin", self.path.to_str().unwrap()) + #[cfg(unix)] - if self.version == "14" { - format!("{}/xtensa-esp32-elf-clang/lib", self.path.to_str().unwrap()) - } else { - format!("{}/esp-clang/lib", self.path.to_str().unwrap()) - } + format!("{}/esp-clang/lib", self.path.to_str().unwrap()) } /// Installs the LLVM toolchain. @@ -98,10 +62,7 @@ impl LlvmToolchain { info!("{} Installing Xtensa elf Clang", emoji::WRENCH); download_file( self.repository_url.clone(), - &format!( - "idf_tool_xtensa_elf_clang.{}", - Self::get_artifact_extension(&self.host_triple) - ), + "idf_tool_xtensa_elf_clang.tar.xz", self.path.to_str().unwrap(), true, )?; @@ -122,60 +83,24 @@ impl LlvmToolchain { /// Create a new instance with default values and proper toolchain version. pub fn new(version: String, minified: bool, host_triple: &HostTriple) -> Self { - let mut file_name: String; - let repository_url: String; - let path: PathBuf; - if version == "14" { - if minified { - file_name = format!( - "xtensa-esp32-elf-llvm{}-{}-{}.{}", - get_release_with_underscores(DEFAULT_LLVM_14_VERSION), - DEFAULT_LLVM_14_VERSION, - host_triple, - Self::get_artifact_extension(host_triple) - ); - repository_url = format!("{}/{}", DEFAULT_LLVM_14_MINIFIED_REPOSITORY, file_name,); - } else { - file_name = format!( - "xtensa-esp32-elf-llvm{}-{}-{}.{}", - get_release_with_underscores(DEFAULT_LLVM_14_VERSION), - DEFAULT_LLVM_14_VERSION, - Self::get_arch(&version, host_triple).unwrap(), - Self::get_artifact_extension(host_triple) - ); - repository_url = format!( - "{}/{}/{}", - DEFAULT_LLVM_14_COMPLETE_REPOSITORY, DEFAULT_LLVM_14_VERSION, file_name - ); - } - path = PathBuf::from(format!( - "{}/{}-{}", - get_tool_path("xtensa-esp32-elf-clang"), - DEFAULT_LLVM_14_VERSION, - host_triple - )); - } else { - // version == "15" - file_name = format!( - "llvm-{}-{}.tar.xz", - DEFAULT_LLVM_15_VERSION, - Self::get_arch(&version, host_triple).unwrap() - ); - if minified { - file_name = format!("libs_{}", file_name); - } - repository_url = format!( - "{}/{}/{}", - DEFAULT_LLVM_15_REPOSITORY, DEFAULT_LLVM_15_VERSION, file_name, - ); - path = PathBuf::from(format!( - "{}/{}-{}", - get_tool_path("xtensa-esp32-elf-clang"), - DEFAULT_LLVM_15_VERSION, - host_triple - )); + let mut file_name = format!( + "llvm-{}-{}.tar.xz", + DEFAULT_LLVM_15_VERSION, + Self::get_arch(&version, host_triple).unwrap() + ); + if minified { + file_name = format!("libs_{}", file_name); } - + let repository_url = format!( + "{}/{}/{}", + DEFAULT_LLVM_REPOSITORY, DEFAULT_LLVM_15_VERSION, file_name, + ); + let path = PathBuf::from(format!( + "{}/{}-{}", + get_tool_path("xtensa-esp32-elf-clang"), + DEFAULT_LLVM_15_VERSION, + host_triple + )); Self { file_name, host_triple: host_triple.clone(), @@ -185,23 +110,3 @@ impl LlvmToolchain { } } } - -/// Gets the parsed version name. -fn get_release_with_underscores(version: &str) -> String { - let version: Vec<&str> = version.split('-').collect(); - let llvm_dot_release = version[1]; - llvm_dot_release.replace('.', "_") -} - -#[cfg(test)] -mod tests { - use crate::toolchain::llvm_toolchain::get_release_with_underscores; - - #[test] - fn test_get_release_with_underscores() { - assert_eq!( - get_release_with_underscores("esp-14.0.0-20220415"), - "14_0_0".to_string() - ); - } -} From 803228087d039502beafee917fe8cc1de36f1f4a Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 12:29:03 +0000 Subject: [PATCH 10/15] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index f37b151..51c9c15 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -9,8 +9,7 @@ use anyhow::{bail, Ok, Result}; use log::{info, warn}; use std::path::{Path, PathBuf}; -const DEFAULT_LLVM_REPOSITORY: &str = - "https://github.com/espressif/llvm-project/releases/download"; +const DEFAULT_LLVM_REPOSITORY: &str = "https://github.com/espressif/llvm-project/releases/download"; const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014"; #[derive(Debug)] @@ -42,10 +41,10 @@ impl LlvmToolchain { /// Gets the binary path. fn get_lib_path(&self) -> String { #[cfg(windows)] - format!("{}/esp-clang/bin", self.path.to_str().unwrap()) - + let llvm_path = format!("{}/esp-clang/bin", self.path.to_str().unwrap()); #[cfg(unix)] - format!("{}/esp-clang/lib", self.path.to_str().unwrap()) + let llvm_path = format!("{}/esp-clang/lib", self.path.to_str().unwrap()); + llvm_path } /// Installs the LLVM toolchain. From 8fd3dccb5022e711d0bffd663179f98dd4caca48 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Tue, 25 Oct 2022 12:31:16 +0000 Subject: [PATCH 11/15] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20clippy=20warn?= =?UTF-8?q?ings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/toolchain/llvm_toolchain.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/toolchain/llvm_toolchain.rs b/src/toolchain/llvm_toolchain.rs index 51c9c15..b41768e 100644 --- a/src/toolchain/llvm_toolchain.rs +++ b/src/toolchain/llvm_toolchain.rs @@ -5,7 +5,7 @@ use crate::{ host_triple::HostTriple, toolchain::{download_file, espidf::get_tool_path}, }; -use anyhow::{bail, Ok, Result}; +use anyhow::{Ok, Result}; use log::{info, warn}; use std::path::{Path, PathBuf}; @@ -28,7 +28,7 @@ pub struct LlvmToolchain { impl LlvmToolchain { /// Gets the name of the LLVM arch based on the host triple. - fn get_arch<'a>(version: &'a str, host_triple: &'a HostTriple) -> Result<&'a str> { + fn get_arch(host_triple: &HostTriple) -> Result<&str> { match host_triple { HostTriple::Aarch64AppleDarwin => Ok("macos-arm64"), HostTriple::X86_64AppleDarwin => Ok("macos"), @@ -85,7 +85,7 @@ impl LlvmToolchain { let mut file_name = format!( "llvm-{}-{}.tar.xz", DEFAULT_LLVM_15_VERSION, - Self::get_arch(&version, host_triple).unwrap() + Self::get_arch(host_triple).unwrap() ); if minified { file_name = format!("libs_{}", file_name); From 71dc527718d0a4986f5d88024dae6d15ddcfd449 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 27 Oct 2022 12:50:55 +0200 Subject: [PATCH 12/15] =?UTF-8?q?chore:=20=E2=9E=95=20Add=20libtinfo5=20de?= =?UTF-8?q?pendency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1af35c5..ef7af03 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -23,7 +23,7 @@ USER ${CONTAINER_USER} WORKDIR /home/${CONTAINER_USER} # openSUSE Tumbleweed/Leap -# RUN zypper install -y git gcc libudev-devel ninja python3 python3-pip make \ +# RUN zypper install -y git gcc libudev-devel ninja python3 python3-pip make libncurses5 \ # && zypper clean # Install Rust diff --git a/README.md b/README.md index 7b93f94..0c3b645 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ sudo dnf -y install git python3 python3-pip gcc systemd-devel ncurses-compat-lib ``` - openSUSE Thumbleweed/Leap ``` -sudo zypper install -y git gcc libudev-devel ninja python3 python3-pip make +sudo zypper install -y git gcc libudev-devel ninja python3 python3-pip make libncurses5 ``` ## Installation From 33be627a1b79638cbca1bbda1bba131f9d55c721 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 27 Oct 2022 13:57:47 +0000 Subject: [PATCH 13/15] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Add=20details=20ab?= =?UTF-8?q?out=20requirements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0c3b645..c551015 100644 --- a/README.md +++ b/README.md @@ -15,30 +15,35 @@ developing applications in Rust for Espressif SoC's. > This application is still under development and should be considered experimental ## Requirements -Before running or installing `espup`, make sure that [`rustup`](https://www.rust-lang.org/tools/install) -and the following dependencies are installed. +Before running or installing `espup`, make sure that [`rustup`](https://www.rust-lang.org/tools/install) and the following dependencies are installed. ### Windows -- [Python](https://www.python.org/downloads/). Version should be between `3.6` and `3.10`. -- [git](https://git-scm.com/download/win) -- Toolchain. Select one of the following: - - [Windows x86_64 GNU](https://github.com/esp-rs/rust-build#windows-x86_64-gnu) - - [Windows x86_64 MSVC](https://github.com/esp-rs/rust-build#windows-x86_64-msvc) - +- [git](https://git-scm.com/download/win). +- [Python](https://www.python.org/downloads/): Only required when installing ESP-IDF. ### Linux - Ubuntu/Debian ```sh sudo apt-get install -y git python3 python3-pip gcc build-essential curl pkg-config libudev-dev libtinfo5 ``` + - `libudev-dev` is only required when installing `cargo-espflash`. + - `python3` and `python3-pip` are only required when installing ESP-IDF. + - `libtinfo5` is required by LLVM 15. - Fedora ```sh sudo dnf -y install git python3 python3-pip gcc systemd-devel ncurses-compat-libs ``` + - `systemd-devel` is only required when installing `cargo-espflash`. + - `python3` and `python3-pip` are only required when installing ESP-IDF. + - `ncurses-compat-libs` is required by LLVM 15. - openSUSE Thumbleweed/Leap ``` sudo zypper install -y git gcc libudev-devel ninja python3 python3-pip make libncurses5 ``` + - `libudev-devel` is only required when installing `cargo-espflash`. + - `python3` and `python3-pip` are only required when installing ESP-IDF. + - `libncurses5` is required by LLVM 15. + ## Installation From d57e4f039fa91fa4232a59d2fd2882e12d9f26ea Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Thu, 27 Oct 2022 20:22:45 +0200 Subject: [PATCH 14/15] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Remove=20experimen?= =?UTF-8?q?tal=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 0c3b645..9cb93c0 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,6 @@ `espup` is a tool for installing and maintaining the required toolchains for developing applications in Rust for Espressif SoC's. -> **Note** -> -> This application is still under development and should be considered experimental - ## Requirements Before running or installing `espup`, make sure that [`rustup`](https://www.rust-lang.org/tools/install) and the following dependencies are installed. From e864b189b391ce68f5f5d0530e58ae485ae7ed9f Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 31 Oct 2022 09:29:04 +0000 Subject: [PATCH 15/15] =?UTF-8?q?style:=20=F0=9F=8E=A8=20Fix=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3f5103c..4edc5a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -159,7 +159,6 @@ fn install(args: InstallOpts) -> Result<()> { }; let llvm = LlvmToolchain::new(args.llvm_version, args.profile_minimal, &host_triple); - debug!( "{} Arguments: - Host triple: {}