From cdbd85747b79efd4b0142391c81222a7a684ae51 Mon Sep 17 00:00:00 2001 From: PaulCombal Date: Fri, 2 Jan 2026 14:04:19 +0100 Subject: [PATCH] Fix builds using the dev profile --- src/main.rs | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 799d830..69f96f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,11 +56,18 @@ fn main() -> Result<()> { .find(|arg| arg.starts_with("--profile=")) .map(|arg| arg.split_at(10).1.to_string()) .unwrap_or_else(|| "release".into()); - std::env::args() + let profile = std::env::args() .skip(2) .find(|arg| arg.starts_with("--target=")) .map(|arg| format!("{}/{}", arg.split_at(9).1, profile)) - .unwrap_or_else(|| profile) + .unwrap_or_else(|| profile); + + // TODO: in-depth metadata parsing + if profile == "dev" { + "debug".to_string() + } else { + profile + } }; let link_deps; let mut link_exclude_list = Vec::with_capacity(0); @@ -82,17 +89,11 @@ fn main() -> Result<()> { } _ => assets = Vec::with_capacity(0), } - match t.get("icon") { - Some(Value::String(s)) => { - icon_path = s; - } - _ => {}, + if let Some(Value::String(s)) = t.get("icon") { + icon_path = s; } - match t.get("desktop_entry") { - Some(Value::String(s)) => { - desktop_entry_path = s; - } - _ => {}, + if let Some(Value::String(s)) = t.get("desktop_entry") { + desktop_entry_path = s; } match t.get("auto_link") { Some(Value::Boolean(v)) => link_deps = v.to_owned(), @@ -201,10 +202,10 @@ fn main() -> Result<()> { let path = &i?.path(); // Skip if it matches the exclude list. - if let Some(file_name) = path.file_name().and_then(|p| p.to_str()) { - if link_exclude_list.iter().any(|p| p.matches(file_name)) { - continue; - } + if let Some(file_name) = path.file_name().and_then(|p| p.to_str()) + && link_exclude_list.iter().any(|p| p.matches(file_name)) + { + continue; } let link = std::fs::read_link(path) @@ -279,8 +280,11 @@ fn main() -> Result<()> { ) })?; } else { - std::fs::copy(desktop_entry_path, appdirpath.join("cargo-appimage.desktop")) - .context(format!("Cannot find {desktop_entry_path}"))?; + std::fs::copy( + desktop_entry_path, + appdirpath.join("cargo-appimage.desktop"), + ) + .context(format!("Cannot find {desktop_entry_path}"))?; } // Copy assets