Skip to content

Commit

Permalink
Add warn message when failed to detect Xtensa Rust (#357)
Browse files Browse the repository at this point in the history
* perf: Add warn message when failed to detect Xtensa Rust

* style: Format log messages

* Add CHANGELOG.md (#358)

* docs: Add CHANGELOG.md

* ci: Ignore changelog updates

* docs: Update changelog
  • Loading branch information
SergioGasquez authored Oct 2, 2023
1 parent 5949af5 commit f360a79
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Add a flag to skip Xtensa Rust version parsing (#352)
- Add warn message when failed to detect Xtensa Rust (#357)

### Changed
- Update dependencies
Expand Down
8 changes: 4 additions & 4 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ pub fn export_environment(export_file: &Path) -> Result<(), Error> {
if cfg!(windows) {
set_environment_variable("PATH", &env::var("PATH").unwrap())?;
warn!(
"{} Your environments variables have been updated! Shell may need to be restarted for changes to be effective.",
"{} Your environments variables have been updated! Shell may need to be restarted for changes to be effective",
emoji::INFO
);
warn!(
"{} A file was created at '{}' showing the injected environment variables.",
"{} A file was created at '{}' showing the injected environment variables",
emoji::INFO,
export_file.display()
);
}
#[cfg(unix)]
if cfg!(unix) {
warn!(
"{} Please, set up the environment variables by running: '. {}'",
"{} Please, set up the environment variables by running: ' {}'",
emoji::INFO,
export_file.display()
);
warn!(
"{} This step must be done every time you open a new terminal.",
"{} This step must be done every time you open a new terminal",
emoji::WARN
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ pub enum Error {
CreateDirectory(String),

#[diagnostic(code(espup::toolchain::rust::query_github))]
#[error("{} Failed to query GitHub API.", emoji::ERROR)]
#[error("{} Failed to query GitHub API", emoji::ERROR)]
GithubQuery,

#[diagnostic(code(espup::toolchain::rust::install_riscv_target))]
#[error(
"{} Failed to Install RISC-V targets for '{0}' toolchain.",
"{} Failed to Install RISC-V targets for '{0}' toolchain",
emoji::ERROR
)]
InstallRiscvTarget(String),

#[diagnostic(code(espup::ivalid_destination))]
#[error(
"{} Invalid export file destination: '{0}'. Please, use an absolute or releative path (including the file and its extension).",
"{} Invalid export file destination: '{0}'. Please, use an absolute or releative path (including the file and its extension)",
emoji::ERROR
)]
InvalidDestination(String),
Expand All @@ -44,7 +44,7 @@ pub enum Error {
MissingRust,

#[diagnostic(code(espup::remove_directory))]
#[error("{} Failed to remove '{0}'.", emoji::ERROR)]
#[error("{} Failed to remove '{0}'", emoji::ERROR)]
RemoveDirectory(String),

#[error(transparent)]
Expand All @@ -55,11 +55,11 @@ pub enum Error {
RustupDetection(String),

#[diagnostic(code(espup::toolchain::rust::serialize_json))]
#[error("{} Failed to serialize json from string.", emoji::ERROR)]
#[error("{} Failed to serialize json from string", emoji::ERROR)]
SerializeJson,

#[diagnostic(code(espup::toolchain::rust::uninstall_riscv_target))]
#[error("{} Failed to uninstall RISC-V target.", emoji::ERROR)]
#[error("{} Failed to uninstall RISC-V target", emoji::ERROR)]
UninstallRiscvTarget,

#[diagnostic(code(espup::toolchain::unsupported_file_extension))]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub mod update {

if let Some(version) = informer.check_version().ok().flatten() {
warn!(
"{} A new version of {name} ('{version}') is available.",
"{} A new version of {name} ('{version}') is available",
emoji::WARN
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/toolchain/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Installable for Gcc {
debug!("{} GCC path: {}", emoji::DEBUG, self.path.display());
if self.path.exists() {
warn!(
"{} Previous installation of GCC exists in: '{}'. Reusing this installation.",
"{} Previous installation of GCC exists in: '{}'. Reusing this installation",
emoji::WARN,
&self.path.display()
);
Expand Down
2 changes: 1 addition & 1 deletion src/toolchain/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Installable for Llvm {

if Path::new(&self.path).exists() {
warn!(
"{} Previous installation of LLVM exists in: '{}'. Reusing this installation.",
"{} Previous installation of LLVM exists in: '{}'. Reusing this installation",
emoji::WARN,
self.path.to_str().unwrap()
);
Expand Down
4 changes: 2 additions & 2 deletions src/toolchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn download_file(
let file_path = format!("{output_directory}/{file_name}");
if Path::new(&file_path).exists() {
warn!(
"{} File '{}' already exists, deleting it before download.",
"{} File '{}' already exists, deleting it before download",
emoji::WARN,
file_path
);
Expand Down Expand Up @@ -271,7 +271,7 @@ pub fn github_query(url: &str) -> Result<serde_json::Value, Error> {
);
headers.insert("X-GitHub-Api-Version", "2022-11-28".parse().unwrap());
if let Some(token) = env::var_os("GITHUB_TOKEN") {
debug!("{} Auth header added.", emoji::DEBUG);
debug!("{} Auth header added", emoji::DEBUG);
headers.insert(
"Authorization",
format!("Bearer {}", token.to_string_lossy())
Expand Down
8 changes: 7 additions & 1 deletion src/toolchain/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,19 @@ impl Installable for XtensaRust {
let output = String::from_utf8_lossy(&rustc_version.stdout);
if rustc_version.status.success() && output.contains(&self.version) {
warn!(
"{} Previous installation of Xtensa Rust {} exists in: '{}'. Reusing this installation.",
"{} Previous installation of Xtensa Rust {} exists in: '{}'. Reusing this installation",
emoji::WARN,
&self.version,
&self.toolchain_destination.display()
);
return Ok(vec![]);
} else {
if !rustc_version.status.success() {
warn!(
"{} Failed to detect version of Xtensa Rust, reinstalling it",
emoji::WARN
);
}
Self::uninstall(&self.toolchain_destination)?;
}
}
Expand Down

0 comments on commit f360a79

Please sign in to comment.