From baa4d9c26f4972c61413a673cca4406760eb2432 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Sun, 10 Sep 2023 23:24:06 -0700 Subject: [PATCH] fix target specific code --- Cargo.toml | 4 ++-- src/app.rs | 2 +- src/image_window.rs | 2 +- src/main.rs | 9 +++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 23dd734..6c4db6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,13 +33,13 @@ rfd = "0.12.0" #serde = { version = "1", features = ["derive"] } # native: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(not(target_family = "wasm"))'.dependencies] env_logger = "0.10" poll-promise = { version = "0.3.0", features = ["smol"] } smol = "1.3.0" # web: -[target.'cfg(target_arch = "wasm32")'.dependencies] +[target.'cfg(target_family = "wasm")'.dependencies] poll-promise = { version = "0.3.0", features = ["web"] } [profile.release] diff --git a/src/app.rs b/src/app.rs index c52d203..89017a6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -185,7 +185,7 @@ impl eframe::App for MetadataTool { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { // For inspiration and more examples, go to https://emilk.github.io/egui - // #[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages! + // #[cfg(not(target_family = "wasm"))] // no File->Quit on web pages! // egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { // // The top panel is often a good place for a menu bar: // egui::menu::bar(ui, |ui| { diff --git a/src/image_window.rs b/src/image_window.rs index f489c21..4a5fd6c 100644 --- a/src/image_window.rs +++ b/src/image_window.rs @@ -146,7 +146,7 @@ fn paste_metadata(mwindow: &ImageWindow, toasts: &RefCell<&mut Toasts>, metadata }); // We do not want to block on wasm, since we're running in an async context already - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(target_family = "wasm"))] promise.block_and_take(); let mut toast_lock = toasts.borrow_mut(); diff --git a/src/main.rs b/src/main.rs index 54ec399..fb37c7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,18 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release // When compiling natively: -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] fn main() -> eframe::Result<()> { env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). + #[cfg(target_family = "windows")] let native_options = eframe::NativeOptions { icon_data: load_favicon(), ..Default::default() }; + #[cfg(not(target_family = "windows"))] + let native_options = eframe::NativeOptions::default(); + eframe::run_native( "MetaYoinker", native_options, @@ -18,7 +22,7 @@ fn main() -> eframe::Result<()> { } // When compiling to web using trunk: -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] fn main() { use poll_promise::Promise; @@ -39,6 +43,7 @@ fn main() { }); } +#[cfg(target_family = "windows")] fn load_favicon() -> Option { let (icon_rgba, icon_width, icon_height) = { let icon = include_bytes!("../assets/icon-256.png");