Merge pull request #1934 from ealmloff/warn-no-renderers-enabled
Warn the user if they try to launch without a renderer selected
This commit is contained in:
4 files changed
+65
-3
No files matched your search
@@ -54,6 +54,8 @@ salvo = ["dioxus-fullstack?/salvo", "ssr", "dioxus-liveview?/salvo"]
|
|||||||
warp = ["dioxus-fullstack?/warp", "ssr", "dioxus-liveview?/warp"]
|
warp = ["dioxus-fullstack?/warp", "ssr", "dioxus-liveview?/warp"]
|
||||||
rocket = ["dioxus-liveview?/rocket"]
|
rocket = ["dioxus-liveview?/rocket"]
|
||||||
tui = ["dioxus-tui", "dioxus-config-macro/tui"]
|
tui = ["dioxus-tui", "dioxus-config-macro/tui"]
|
||||||
|
# This feature just disables the no-renderer-enabled warning
|
||||||
|
third-party-renderer = []
|
||||||
|
|
||||||
# This feature enables some nightly flags that make it more clear what structs/methods are available in each feature
|
# This feature enables some nightly flags that make it more clear what structs/methods are available in each feature
|
||||||
nightly-doc = []
|
nightly-doc = []
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
fn main() {
|
||||||
|
// Warn the user if they enabled the launch feature without any renderers
|
||||||
|
if feature_enabled("launch") {
|
||||||
|
if feature_enabled("third-party-renderer") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let liveview_renderers = ["liveview", "axum", "salvo", "warp", "rocket"];
|
||||||
|
let fullstack_renderers = ["axum", "salvo", "warp"];
|
||||||
|
let client_renderers = ["desktop", "mobile", "web", "tui"];
|
||||||
|
let client_renderer_selected = client_renderers
|
||||||
|
.iter()
|
||||||
|
.any(|renderer| feature_enabled(renderer));
|
||||||
|
if feature_enabled("fullstack") {
|
||||||
|
let server_fullstack_enabled = fullstack_renderers
|
||||||
|
.iter()
|
||||||
|
.any(|renderer| feature_enabled(renderer));
|
||||||
|
if !server_fullstack_enabled && !client_renderer_selected {
|
||||||
|
println!("cargo:warning=You have enabled the launch and fullstack features, but have not enabled any renderers. The application will not be able to launch. Try enabling one of the following renderers: {} for the server or one of the following renderers: {} for the client.", fullstack_renderers.join(", "), client_renderers.join(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if feature_enabled("liveview") {
|
||||||
|
let server_selected = liveview_renderers
|
||||||
|
.iter()
|
||||||
|
.any(|renderer| feature_enabled(renderer));
|
||||||
|
if !server_selected {
|
||||||
|
println!("cargo:warning=You have enabled the launch and liveview features, but have not enabled any liveview renderers. The application will not be able to launch. Try enabling one of the following renderers: {}", liveview_renderers.join(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !client_renderer_selected {
|
||||||
|
println!("cargo:warning=You have enabled the launch feature, but have not enabled any client renderers. The application will not be able to launch. Try enabling one of the following renderers: {}, fullstack or liveview", client_renderers.join(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn feature_enabled(feature: &str) -> bool {
|
||||||
|
let feature = "CARGO_FEATURE_".to_owned() + &feature.to_uppercase().replace('-', "_");
|
||||||
|
println!("cargo:rerun-if-env-changed={}", feature);
|
||||||
|
std::env::var(feature).is_ok()
|
||||||
|
}
|
||||||
@@ -161,15 +161,26 @@ mod current_platform {
|
|||||||
#[cfg(all(feature = "desktop", not(feature = "fullstack")))]
|
#[cfg(all(feature = "desktop", not(feature = "fullstack")))]
|
||||||
pub use dioxus_desktop::launch::*;
|
pub use dioxus_desktop::launch::*;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "mobile", not(feature = "fullstack")))]
|
||||||
|
pub use dioxus_desktop::launch::*;
|
||||||
|
|
||||||
#[cfg(feature = "fullstack")]
|
#[cfg(feature = "fullstack")]
|
||||||
pub use dioxus_fullstack::launch::*;
|
pub use dioxus_fullstack::launch::*;
|
||||||
|
|
||||||
#[cfg(all(feature = "web", not(any(feature = "desktop", feature = "fullstack"))))]
|
#[cfg(all(
|
||||||
|
feature = "web",
|
||||||
|
not(any(feature = "desktop", feature = "mobile", feature = "fullstack"))
|
||||||
|
))]
|
||||||
pub use dioxus_web::launch::*;
|
pub use dioxus_web::launch::*;
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
feature = "liveview",
|
feature = "liveview",
|
||||||
not(any(feature = "web", feature = "desktop", feature = "fullstack"))
|
not(any(
|
||||||
|
feature = "web",
|
||||||
|
feature = "desktop",
|
||||||
|
feature = "mobile",
|
||||||
|
feature = "fullstack"
|
||||||
|
))
|
||||||
))]
|
))]
|
||||||
pub use dioxus_liveview::launch::*;
|
pub use dioxus_liveview::launch::*;
|
||||||
|
|
||||||
@@ -179,6 +190,7 @@ mod current_platform {
|
|||||||
feature = "liveview",
|
feature = "liveview",
|
||||||
feature = "web",
|
feature = "web",
|
||||||
feature = "desktop",
|
feature = "desktop",
|
||||||
|
feature = "mobile",
|
||||||
feature = "fullstack"
|
feature = "fullstack"
|
||||||
))
|
))
|
||||||
))]
|
))]
|
||||||
@@ -187,6 +199,7 @@ mod current_platform {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
feature = "liveview",
|
feature = "liveview",
|
||||||
feature = "desktop",
|
feature = "desktop",
|
||||||
|
feature = "mobile",
|
||||||
feature = "web",
|
feature = "web",
|
||||||
feature = "tui",
|
feature = "tui",
|
||||||
feature = "fullstack"
|
feature = "fullstack"
|
||||||
@@ -196,6 +209,7 @@ mod current_platform {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
feature = "liveview",
|
feature = "liveview",
|
||||||
feature = "desktop",
|
feature = "desktop",
|
||||||
|
feature = "mobile",
|
||||||
feature = "web",
|
feature = "web",
|
||||||
feature = "tui",
|
feature = "tui",
|
||||||
feature = "fullstack"
|
feature = "fullstack"
|
||||||
@@ -205,6 +219,10 @@ mod current_platform {
|
|||||||
contexts: Vec<Box<super::ValidContext>>,
|
contexts: Vec<Box<super::ValidContext>>,
|
||||||
platform_config: (),
|
platform_config: (),
|
||||||
) {
|
) {
|
||||||
|
#[cfg(feature = "third-party-renderer")]
|
||||||
|
panic!("No first party renderer feature enabled. It looks like you are trying to use a third party renderer. You will need to use the launch function from the third party renderer crate.");
|
||||||
|
|
||||||
|
panic!("No platform feature enabled. Please enable one of the following features: liveview, desktop, mobile, web, tui, fullstack to use the launch API.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
|
|||||||
repository = "https://github.com/DioxusLabs/dioxus/"
|
repository = "https://github.com/DioxusLabs/dioxus/"
|
||||||
homepage = "https://dioxuslabs.com"
|
homepage = "https://dioxuslabs.com"
|
||||||
keywords = ["dom", "ui", "gui", "react", "wasm"]
|
keywords = ["dom", "ui", "gui", "react", "wasm"]
|
||||||
rust-version = "1.60.0"
|
rust-version = "1.64.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user