From 0a3b794a1cc3a9c215ca37b0d0510f70850778b5 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 1 Dec 2023 15:56:14 -0600 Subject: [PATCH 1/3] add a warning about wry gnu support to dioxus desktop --- packages/desktop/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/desktop/src/lib.rs b/packages/desktop/src/lib.rs index 63a8914f3..13d52b032 100644 --- a/packages/desktop/src/lib.rs +++ b/packages/desktop/src/lib.rs @@ -19,6 +19,17 @@ mod webview; #[cfg(any(target_os = "ios", target_os = "android"))] mod mobile_shortcut; +// WARN about wry support on windows gnu targets. GNU windows targets don't work well in wry currently +#[cfg(all(windows, target_env = "gnu"))] +mod wry_gnu_warning { + #[allow(dead_code)] + #[must_use = "GNU windows targets can have issues with Wry. Using the MSVC toolchain is recommended"] + struct WryGnuWarning; + const _: () = { + let dont_use_gnu = WryGnuWarning; + }; +} + use crate::query::QueryResult; pub use cfg::{Config, WindowCloseBehaviour}; pub use desktop_context::DesktopContext; From a4600294c5c5dfc9c130b0db652d7ba2d036a1e8 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 1 Dec 2023 22:17:51 -0600 Subject: [PATCH 2/3] allow users to disable the warning in a feature --- packages/desktop/Cargo.toml | 1 + packages/desktop/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index dcb994120..f0ea9e189 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -59,6 +59,7 @@ devtools = ["wry/devtools"] tray = ["wry/tray"] dox = ["wry/dox"] hot-reload = ["dioxus-hot-reload"] +gnu = [] [package.metadata.docs.rs] default-features = false diff --git a/packages/desktop/src/lib.rs b/packages/desktop/src/lib.rs index 13d52b032..9a5ba6c64 100644 --- a/packages/desktop/src/lib.rs +++ b/packages/desktop/src/lib.rs @@ -20,10 +20,10 @@ mod webview; mod mobile_shortcut; // WARN about wry support on windows gnu targets. GNU windows targets don't work well in wry currently -#[cfg(all(windows, target_env = "gnu"))] +#[cfg(all(windows, target_env = "gnu", not(feature = "gnu")))] mod wry_gnu_warning { #[allow(dead_code)] - #[must_use = "GNU windows targets can have issues with Wry. Using the MSVC toolchain is recommended"] + #[must_use = "GNU windows targets have some limitations within Wry. Using the MSVC windows toolchain is recommended. If you would like to use continue using GNU, you can read https://github.com/wravery/webview2-rs#cross-compilation and disable this warning by adding the gnu feature to dioxus-desktop in your Cargo.toml"] struct WryGnuWarning; const _: () = { let dont_use_gnu = WryGnuWarning; From 7d2bbda53dc94b07cfe0aad8499b3eb408ecce99 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 7 Dec 2023 07:10:53 -0600 Subject: [PATCH 3/3] move gnu warning to build script --- packages/desktop/build.rs | 9 +++++++++ packages/desktop/src/lib.rs | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 packages/desktop/build.rs diff --git a/packages/desktop/build.rs b/packages/desktop/build.rs new file mode 100644 index 000000000..2061732e8 --- /dev/null +++ b/packages/desktop/build.rs @@ -0,0 +1,9 @@ +fn main() { + // WARN about wry support on windows gnu targets. GNU windows targets don't work well in wry currently + if std::env::var("CARGO_CFG_WINDOWS").is_ok() + && std::env::var("CARGO_CFG_TARGET_ENV").unwrap() == "gnu" + && !cfg!(feature = "gnu") + { + println!("cargo:warning=GNU windows targets have some limitations within Wry. Using the MSVC windows toolchain is recommended. If you would like to use continue using GNU, you can read https://github.com/wravery/webview2-rs#cross-compilation and disable this warning by adding the gnu feature to dioxus-desktop in your Cargo.toml") + } +} diff --git a/packages/desktop/src/lib.rs b/packages/desktop/src/lib.rs index 9a5ba6c64..63a8914f3 100644 --- a/packages/desktop/src/lib.rs +++ b/packages/desktop/src/lib.rs @@ -19,17 +19,6 @@ mod webview; #[cfg(any(target_os = "ios", target_os = "android"))] mod mobile_shortcut; -// WARN about wry support on windows gnu targets. GNU windows targets don't work well in wry currently -#[cfg(all(windows, target_env = "gnu", not(feature = "gnu")))] -mod wry_gnu_warning { - #[allow(dead_code)] - #[must_use = "GNU windows targets have some limitations within Wry. Using the MSVC windows toolchain is recommended. If you would like to use continue using GNU, you can read https://github.com/wravery/webview2-rs#cross-compilation and disable this warning by adding the gnu feature to dioxus-desktop in your Cargo.toml"] - struct WryGnuWarning; - const _: () = { - let dont_use_gnu = WryGnuWarning; - }; -} - use crate::query::QueryResult; pub use cfg::{Config, WindowCloseBehaviour}; pub use desktop_context::DesktopContext;