fix build file

Yara created

Change summary

crates/gpui/src/window.rs       |  1 
crates/gpui_macos/src/window.rs |  1 
crates/zed/build.rs             | 48 +++++++++++++++-------------------
3 files changed, 22 insertions(+), 28 deletions(-)

Detailed changes

crates/gpui/src/window.rs 🔗

@@ -1156,7 +1156,6 @@ impl Window {
                 show,
                 display_id,
                 window_min_size,
-                #[cfg(any(target_os = "linux", target_os = "freebsd"))]
                 icon,
                 #[cfg(target_os = "macos")]
                 tabbing_identifier,

crates/gpui_macos/src/window.rs 🔗

@@ -628,6 +628,7 @@ impl MacWindow {
             display_id,
             window_min_size,
             tabbing_identifier,
+            ..
         }: WindowParams,
         foreground_executor: ForegroundExecutor,
         background_executor: BackgroundExecutor,

crates/zed/build.rs 🔗

@@ -1,6 +1,7 @@
 #![allow(clippy::disallowed_methods, reason = "build scripts are exempt")]
-use std::path::Path;
+use std::path::PathBuf;
 use std::process::Command;
+use std::str::FromStr;
 
 fn main() {
     #[cfg(target_os = "linux")]
@@ -231,49 +232,42 @@ fn main() {
     prepare_app_icon_x11();
 }
 
-fn icon_path() -> &'static Path {
+fn icon_path() -> PathBuf {
     let release_channel = option_env!("RELEASE_CHANNEL").unwrap_or("dev");
-    let icon = match release_channel {
-        "stable" => "resources/app-icon.png",
-        "preview" => "resources/app-icon-preview.png",
-        "nightly" => "resources/app-icon-nightly.png",
-        "dev" | _ => "resources/app-icon-dev.png",
+    let channel = match release_channel {
+        "stable" => "",
+        "preview" => "-preview",
+        "nightly" => "-nightly",
+        "dev" => "-dev",
+        _ => "-dev",
     };
 
-    Path::new(icon)
+    #[cfg(windows)]
+    let icon = format!("resources/windows/app-icon{}.ico", channel);
+    #[cfg(not(windows))]
+    let icon = format!("resources/app-icon{}.png", channel);
+
+    PathBuf::from_str(&icon).unwrap()
 }
 
 #[cfg(any(target_os = "linux", target_os = "freebsd"))]
 fn prepare_app_icon_x11() {
-    use image::{DynamicImage, ImageReader, ImageResult, imageops};
+    use image::{ImageReader, imageops};
     use std::env;
     use std::path::Path;
 
     let out_dir = env::var("OUT_DIR").unwrap();
 
-    let resized_image =
-        match || -> ImageResult<DynamicImage> { Ok(ImageReader::open(icon_path())?.decode()?) }() {
-            Err(msg) => {
-                eprintln!("failed to read or decode {}: {msg}", icon_path().display());
-                std::process::exit(1);
-            }
-            Ok(image) => imageops::resize(&image, 256, 256, imageops::FilterType::Lanczos3),
-        };
+    let resized_image = ImageReader::open(icon_path())
+        .unwrap()
+        .decode()
+        .unwrap()
+        .resize(256, 256, imageops::FilterType::Lanczos3);
 
     // name should match include_bytes! call in src/zed.rs
     let icon_out_path = Path::new(&out_dir).join("app_icon.png");
     resized_image.save(&icon_out_path).expect("saving app icon");
 
-    // verify icon can be read and decoded
-    if let Err(msg) = ImageReader::open(&icon_out_path).unwrap().decode() {
-        eprintln!(
-            "error verifying {}: {msg} (resized from {})",
-            icon_out_path.display(),
-            icon_path().display(),
-        );
-        std::process::exit(1);
-    }
-
     println!("cargo:rerun-if-env-changed=RELEASE_CHANNEL");
     println!("cargo:rerun-if-changed={}", icon_path().to_string_lossy());
 }