mirror of
https://github.com/esp-rs/espup.git
synced 2025-10-02 15:14:56 +00:00
feat: 🔥 Remove llvm 14 argument
This commit is contained in:
parent
010a1ca4f8
commit
51a8f10f03
@ -81,7 +81,7 @@ pub struct InstallOpts {
|
|||||||
#[arg(short = 'c', long, default_value = "cargo-espflash")]
|
#[arg(short = 'c', long, default_value = "cargo-espflash")]
|
||||||
pub extra_crates: String,
|
pub extra_crates: String,
|
||||||
/// LLVM version.
|
/// 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,
|
pub llvm_version: String,
|
||||||
/// Verbosity level of the logs.
|
/// Verbosity level of the logs.
|
||||||
#[arg(short = 'l', long, default_value = "info", value_parser = ["debug", "info", "warn", "error"])]
|
#[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<String> = Vec::new();
|
let mut exports: Vec<String> = Vec::new();
|
||||||
let export_file = args.export_file.clone();
|
let export_file = args.export_file.clone();
|
||||||
let rust_toolchain = RustToolchain::new(&args.toolchain_version, &host_triple);
|
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);
|
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!(
|
debug!(
|
||||||
"{} Arguments:
|
"{} Arguments:
|
||||||
|
@ -9,14 +9,7 @@ use anyhow::{bail, Ok, Result};
|
|||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
// LLVM 14
|
const DEFAULT_LLVM_REPOSITORY: &str =
|
||||||
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 =
|
|
||||||
"https://github.com/espressif/llvm-project/releases/download";
|
"https://github.com/espressif/llvm-project/releases/download";
|
||||||
const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014";
|
const DEFAULT_LLVM_15_VERSION: &str = "esp-15.0.0-20221014";
|
||||||
|
|
||||||
@ -28,60 +21,31 @@ pub struct LlvmToolchain {
|
|||||||
pub host_triple: HostTriple,
|
pub host_triple: HostTriple,
|
||||||
/// LLVM Toolchain path.
|
/// LLVM Toolchain path.
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
/// The repository containing LVVM sources.
|
/// The repository containing LLVM sources.
|
||||||
pub repository_url: String,
|
pub repository_url: String,
|
||||||
/// LLVM Version ["14", "15"].
|
/// LLVM Version ["15"].
|
||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LlvmToolchain {
|
impl LlvmToolchain {
|
||||||
/// Gets the name of the LLVM arch based on the host triple.
|
/// 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<'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 {
|
match host_triple {
|
||||||
HostTriple::X86_64PcWindowsMsvc | HostTriple::X86_64PcWindowsGnu => "zip",
|
HostTriple::Aarch64AppleDarwin => Ok("macos-arm64"),
|
||||||
_ => "tar.xz",
|
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.
|
/// Gets the binary path.
|
||||||
fn get_lib_path(&self) -> String {
|
fn get_lib_path(&self) -> String {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if self.version == "14" {
|
format!("{}/esp-clang/bin", self.path.to_str().unwrap())
|
||||||
format!("{}/xtensa-esp32-elf-clang/bin", self.path.to_str().unwrap())
|
|
||||||
} else {
|
|
||||||
format!("{}/esp-clang/lib", self.path.to_str().unwrap())
|
|
||||||
}
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
if self.version == "14" {
|
format!("{}/esp-clang/lib", self.path.to_str().unwrap())
|
||||||
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.
|
/// Installs the LLVM toolchain.
|
||||||
@ -98,10 +62,7 @@ impl LlvmToolchain {
|
|||||||
info!("{} Installing Xtensa elf Clang", emoji::WRENCH);
|
info!("{} Installing Xtensa elf Clang", emoji::WRENCH);
|
||||||
download_file(
|
download_file(
|
||||||
self.repository_url.clone(),
|
self.repository_url.clone(),
|
||||||
&format!(
|
"idf_tool_xtensa_elf_clang.tar.xz",
|
||||||
"idf_tool_xtensa_elf_clang.{}",
|
|
||||||
Self::get_artifact_extension(&self.host_triple)
|
|
||||||
),
|
|
||||||
self.path.to_str().unwrap(),
|
self.path.to_str().unwrap(),
|
||||||
true,
|
true,
|
||||||
)?;
|
)?;
|
||||||
@ -122,60 +83,24 @@ impl LlvmToolchain {
|
|||||||
|
|
||||||
/// Create a new instance with default values and proper toolchain version.
|
/// Create a new instance with default values and proper toolchain version.
|
||||||
pub fn new(version: String, minified: bool, host_triple: &HostTriple) -> Self {
|
pub fn new(version: String, minified: bool, host_triple: &HostTriple) -> Self {
|
||||||
let mut file_name: String;
|
let mut file_name = format!(
|
||||||
let repository_url: String;
|
"llvm-{}-{}.tar.xz",
|
||||||
let path: PathBuf;
|
DEFAULT_LLVM_15_VERSION,
|
||||||
if version == "14" {
|
Self::get_arch(&version, host_triple).unwrap()
|
||||||
if minified {
|
);
|
||||||
file_name = format!(
|
if minified {
|
||||||
"xtensa-esp32-elf-llvm{}-{}-{}.{}",
|
file_name = format!("libs_{}", file_name);
|
||||||
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 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 {
|
Self {
|
||||||
file_name,
|
file_name,
|
||||||
host_triple: host_triple.clone(),
|
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()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user