Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions packages/cli/src/build/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,18 @@ impl BuildRequest {
},
None if !using_dioxus_explicitly => None,
None => match enabled_renderers.as_slice() {
[] => None, // Wait until we resolve everything else first then we will resolve it from the triple
// Wait until we resolve everything else first then we will resolve it from the triple if there are no
// default renderers that are compatible with the target args
[] => None,
[(renderer, _)] if !renderer.compatible_with(&args.target, target_alias) => {
// The user passed --target desktop, but the default renderer was web. Disable the web renderer and re-enable the features for the
// desktop or mobile platform later
features.extend(Self::rendererless_features(main_package));
no_default_features = true;
None
}

// If there is a single default renderer that is compatible with the current target, use it
[(renderer, feature)] => {
let targeting_mobile = match (&args.target, target_alias) {
(_, TargetAlias::Android | TargetAlias::Ios) => true,
Expand Down Expand Up @@ -3503,10 +3514,8 @@ impl BuildRequest {
}

fn is_wasm_or_wasi(&self) -> bool {
matches!(
self.triple.architecture,
target_lexicon::Architecture::Wasm32 | target_lexicon::Architecture::Wasm64
) || self.triple.operating_system == target_lexicon::OperatingSystem::Wasi
triple_is_wasm(&self.triple)
|| self.triple.operating_system == target_lexicon::OperatingSystem::Wasi
}

/// Does the app specify:
Expand Down Expand Up @@ -5064,3 +5073,10 @@ We checked the folders:
))
}
}

pub(crate) fn triple_is_wasm(triple: &Triple) -> bool {
matches!(
triple.architecture,
Architecture::Wasm32 | Architecture::Wasm64
)
}
20 changes: 19 additions & 1 deletion packages/cli/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::Display;
use std::str::FromStr;
use target_lexicon::{Architecture, Environment, OperatingSystem, Triple};

use crate::Workspace;
use crate::{triple_is_wasm, Workspace};

#[derive(
Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Debug, Default,
Expand Down Expand Up @@ -278,6 +278,24 @@ impl Renderer {
_ => Self::Webview,
}
}

pub(crate) fn compatible_with(
&self,
target: &Option<Triple>,
target_alias: TargetAlias,
) -> bool {
let web_target = match (target, target_alias) {
(Some(triple), _) if triple_is_wasm(triple) => true,
(None, TargetAlias::Wasm) => true,
_ => false,
};
// Web builds are only compatible with the web, liveview, and server renderers
if web_target {
matches!(self, Self::Web | Self::Liveview | Self::Server)
} else {
false
}
}
}

#[derive(Debug)]
Expand Down
Loading