Skip to content

Commit

Permalink
fix target specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeWaka committed Sep 11, 2023
1 parent f989103 commit baa4d9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
2 changes: 1 addition & 1 deletion src/image_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand All @@ -39,6 +43,7 @@ fn main() {
});
}

#[cfg(target_family = "windows")]
fn load_favicon() -> Option<eframe::IconData> {
let (icon_rgba, icon_width, icon_height) = {
let icon = include_bytes!("../assets/icon-256.png");
Expand Down

0 comments on commit baa4d9c

Please sign in to comment.