From 0829e8399beb5248e15b086a8979dffe576927fd Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 11 Sep 2023 16:04:25 -0300 Subject: [PATCH] fix icon loading --- core/tauri-codegen/src/context.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs index 7d3f2328a7cc..0ccd8cf72440 100644 --- a/core/tauri-codegen/src/context.rs +++ b/core/tauri-codegen/src/context.rs @@ -470,15 +470,20 @@ fn ico_icon>( let width = entry.width(); let height = entry.height(); - let out_path = out_dir.join(path.file_name().unwrap()); + let icon_file_name = path.file_name().unwrap(); + let out_path = out_dir.join(icon_file_name); write_if_changed(&out_path, &rgba).map_err(|error| EmbeddedAssetsError::AssetWrite { path: path.to_owned(), error, })?; - let out_path = out_path.display().to_string(); - - let icon = quote!(Some(#root::Icon::Rgba { rgba: include_bytes!(#out_path).to_vec(), width: #width, height: #height })); + let icon_file_name = icon_file_name.to_str().unwrap(); + let icon = quote!(Some( + #root::Icon::Rgba { + rgba: include_bytes!(concat!(std::env!("OUT_DIR"), "/", #icon_file_name)).to_vec(), + width: #width, + height: #height + })); Ok(icon) } @@ -528,16 +533,17 @@ fn png_icon>( let width = reader.info().width; let height = reader.info().height; - let out_path = out_dir.join(path.file_name().unwrap()); + let icon_file_name = path.file_name().unwrap(); + let out_path = out_dir.join(icon_file_name); write_if_changed(&out_path, &buffer).map_err(|error| EmbeddedAssetsError::AssetWrite { path: path.to_owned(), error, })?; - let icon_path = path.file_name().unwrap().to_str().unwrap().to_string(); + let icon_file_name = icon_file_name.to_str().unwrap(); let icon = quote!(Some( #root::Icon::Rgba { - rgba: include_bytes!(#icon_path).to_vec(), + rgba: include_bytes!(concat!(std::env!("OUT_DIR"), "/", #icon_file_name)).to_vec(), width: #width, height: #height, }