From 8278b4356f57eb29219d32e368c145bfe16de069 Mon Sep 17 00:00:00 2001 From: Sergio Ribera <56278796+SergioRibera@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:42:09 -0400 Subject: [PATCH] fix: macos compilation --- crates/sss_code/src/main.rs | 2 +- crates/sss_lib/src/error.rs | 6 +++++- crates/sss_lib/src/out.rs | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/sss_code/src/main.rs b/crates/sss_code/src/main.rs index 6c51b49..c6c6cfd 100644 --- a/crates/sss_code/src/main.rs +++ b/crates/sss_code/src/main.rs @@ -101,7 +101,7 @@ fn main() -> Result<(), Report> { ss.find_syntax_by_extension(ext) .wrap_err("Extension not found from extension argument")? } else { - ss.find_syntax_for_file(&content.filename())? + ss.find_syntax_for_file(content.filename())? .wrap_err("Extension not found from stdin or file")? }; diff --git a/crates/sss_lib/src/error.rs b/crates/sss_lib/src/error.rs index 30a23dc..2859119 100644 --- a/crates/sss_lib/src/error.rs +++ b/crates/sss_lib/src/error.rs @@ -1,8 +1,11 @@ use font_kit::error::{FontLoadingError, GlyphLoadingError, SelectionError}; use image::ImageError; -use notify_rust::{error::Error as NotificationError, ImageError as NotificationImageError}; +use notify_rust::error::Error as NotificationError; use std::num::ParseIntError; +#[cfg(all(unix, not(target_os = "macos")))] +use notify_rust::ImageError as NotificationImageError; + use thiserror::Error; #[derive(Debug, Error)] @@ -14,6 +17,7 @@ pub enum ImagenGeneration { Font(#[from] FontError), Image(#[from] ImageError), Notification(#[from] NotificationError), + #[cfg(all(unix, not(target_os = "macos")))] NotificationImage(#[from] NotificationImageError), #[error("{0}")] Custom(String), diff --git a/crates/sss_lib/src/out.rs b/crates/sss_lib/src/out.rs index 7d5e5f9..b29eccc 100644 --- a/crates/sss_lib/src/out.rs +++ b/crates/sss_lib/src/out.rs @@ -2,7 +2,7 @@ use image::codecs::png::PngEncoder; use image::{ImageBuffer, ImageEncoder, Rgba}; use notify_rust::Notification; -#[cfg(target_os = "linux")] +#[cfg(all(unix, not(target_os = "macos")))] use notify_rust::Image; use crate::{error, str_to_format}; @@ -32,7 +32,7 @@ pub fn make_output( if show_notify { tracing::trace!("Show notification"); - #[cfg(all(unix, not(target_os = "macos"), not(target_os = "windows")))] + #[cfg(all(unix, not(target_os = "macos")))] Notification::new() .summary("Image generated") .body(&format!("Image stored in {output}")) @@ -42,7 +42,7 @@ pub fn make_output( img.to_vec(), )?) .show()?; - #[cfg(all(target_os = "macos", target_os = "windows"))] + #[cfg(not(unix))] Notification::new() .summary("Image generated") .body(&format!("Image stored in {output}"))