Skip to content
Merged
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
40 changes: 28 additions & 12 deletions packages/cli/src/cli/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,35 @@ impl Bundle {
bail!("\n\nBundle publisher was not provided in `Dioxus.toml`. Add it as:\n\n[bundle]\npublisher = \"MyCompany\"\n\n");
}

/// Resolve an icon path relative to the crate dir
fn canonicalize_icon_path(build: &BuildRequest, icon: &mut String) -> Result<(), Error> {
let icon_path = build
.crate_dir()
.join(&icon)
.canonicalize()
.with_context(|| format!("Failed to canonicalize path to icon {icon:?}"))?;
*icon = icon_path.to_string_lossy().to_string();
Ok(())
}

// Resolve bundle.icon relative to the crate dir
if let Some(icons) = bundle_settings.icon.as_mut() {
for icon in icons.iter_mut() {
canonicalize_icon_path(build, icon)?;
}
}

#[allow(deprecated)]
if cfg!(windows) {
// Resolve bundle.windows.icon_path relative to the crate dir
let mut windows_icon_path = bundle_settings
.windows
.icon_path
.to_string_lossy()
.to_string();
canonicalize_icon_path(build, &mut windows_icon_path)?;
bundle_settings.windows.icon_path = PathBuf::from(&windows_icon_path);

let windows_icon_override = krate.config.bundle.windows.as_ref().map(|w| &w.icon_path);
if windows_icon_override.is_none() {
let icon_path = bundle_settings
Expand All @@ -197,18 +225,6 @@ impl Bundle {
}
}

// resolve the icon relative to the crate, not the current working directory
if let Some(icons) = bundle_settings.icon.as_mut() {
for icon in icons {
let icon_path = build
.crate_dir()
.join(&icon)
.canonicalize()
.with_context(|| format!("Failed to canonicalize path to icon {icon:?}"))?;
*icon = icon_path.to_string_lossy().to_string();
}
}

if bundle_settings.resources_map.is_none() {
bundle_settings.resources_map = Some(HashMap::new());
}
Expand Down