From 69f6df17ab62fd3eb08df6c45ed6b1abe7e96986 Mon Sep 17 00:00:00 2001 From: NitinKM <70827815+NewtonChutney@users.noreply.github.com> Date: Sun, 28 Jan 2024 15:01:10 +0530 Subject: [PATCH] Add icon to Windows executable (#9104) * injecting the icon through a resource file, no extra deps * formatted * scripted rc compilation * formatted and restructured * simplified conditional func call --- contrib/helix-256p.ico | Bin 0 -> 270398 bytes helix-term/build.rs | 146 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 contrib/helix-256p.ico diff --git a/contrib/helix-256p.ico b/contrib/helix-256p.ico new file mode 100644 index 0000000000000000000000000000000000000000..16781cc10b53d50b51f56c7a1d95473eec2a8fb8 GIT binary patch literal 270398 zcmeHw4Qv!wwx)-N7!)BEp$J7N!U#nXiXs$6(FmbYKoN=%LTr{8md7w`CNGa6#$f(2 zZHI1bLm0wj2w}kXFj0&P0H7e0XbpP!ofYSw_OG;pJ3(J1i!W#AKl`uKwDdY{aHSJfUDhBc78 z1_oQoo(13E2S&2+Uibp$f9~q$D_H}s&;YppBtY-;x(xE3`R|IF<3g|oa@W96>*BHC z`)fcm@W>?h$p`TBKX>)>m8^k+X#m{)32+R!4~XZv*-z$w!D^5*W(}Cv0JuIC*ah6o zgZIKuF#pY00bjuya9jiOoZZ&NE5Z587Vw_=?|2PzhO7be8W?I_G6sB~2b=;PTF8C! z0sQ(qP60>bUpjZe9#h+GtlH89Y+_&M)ojV@O~2bz6sEa%N6{z`;(vl1vZb?t@8NZ5^%jM#(UyEA%bWBa|JFQXK%3v z23udJxZEW`3y{m4T`PS8^WWn7HIrOtppnM*sh@u*#(BYg`aBDaHs}2Ew90Y0 zv%vWi!1sWaJkB*O=6?ZA2K-(M=y9L;f3&@Z$NdUeJ(guX&|3Bk_`Vkyb_wr=zhM4b zR?FrR0>5Vf$!&i1^Z#&oTLZuEH>XxtosBhkC@!}Gxau> z4`1uN2Eg~1fTKV@ak+Y2wc{A`-(eH!*m{V@{Ptye_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*^gxn2bKO@`Q%ODO$NGm5?T1FYYR>JW++QQJ`X^OmA zBTv<^Mx5FSRci;QrWlx7JCLVXKt!8<$_<7x%eC6Uxk(DpYA02mRJ@eyo0GCnPCr?k zBu^<`l02n&N%BZM{TE{2wD%W^%SAnC<#Dn8^F>@lPw-~tT+Q_f?UV`@YUHtNaAi=~ zp++83(!~GqHnduv&<>f6aU(2oA|JyE>bxL*0CzCIGqo{lOvtClwlxnh;_FSR@* zB}0@ zOJ5wL0*ddrL|h-|EFI91i{i;us3TAKl!)&2vyqqbhbjz;?}_{qN1&lpdAxWyPfsqi zL&-GjTwh9p*k43P9uz`+-qVq*#HeD`*^2%W+QEsM_jigsp&fmBDGtZ~G_P!w>w|G2 zzC2d@Pg$om;)nWnv_kxXe0It~)d9$Zs-G!e zAE!PoHRn7|){aI>`Ijag(f&+&f2S4Vm&TYyLS4&)iN19_=VqN+pL-o>j io::Result { + let find_reg_key = process::Command::new("reg") + .arg("query") + .arg(r"HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots") + .arg("/reg:32") + .arg("/v") + .arg("KitsRoot10") + .output(); + + match find_reg_key { + Err(find_reg_key) => { + return Err(io::Error::new( + io::ErrorKind::Other, + format!("Failed to run registry query: {}", find_reg_key), + )) + } + Ok(find_reg_key) => { + if find_reg_key.status.code().unwrap() != 0 { + return Err(io::Error::new( + io::ErrorKind::Other, + "Can not find Windows SDK", + )); + } else { + let lines = String::from_utf8(find_reg_key.stdout) + .expect("Should be able to parse the output"); + let mut lines: Vec<&str> = lines.lines().collect(); + let mut rc_exe_paths: Vec = Vec::new(); + lines.reverse(); + for line in lines { + if line.trim().starts_with("KitsRoot") { + let kit: String = line + .chars() + .skip(line.find("REG_SZ").unwrap() + 6) + .skip_while(|c| c.is_whitespace()) + .collect(); + + let p = PathBuf::from(&kit); + let rc = if cfg!(target_arch = "x86_64") { + p.join(r"bin\x64\rc.exe") + } else { + p.join(r"bin\x86\rc.exe") + }; + + if rc.exists() { + println!("{:?}", rc); + rc_exe_paths.push(rc.to_owned()); + } + + if let Ok(bin) = p.join("bin").read_dir() { + for e in bin.filter_map(|e| e.ok()) { + let p = if cfg!(target_arch = "x86_64") { + e.path().join(r"x64\rc.exe") + } else { + e.path().join(r"x86\rc.exe") + }; + if p.exists() { + println!("{:?}", p); + rc_exe_paths.push(p.to_owned()); + } + } + } + } + } + if rc_exe_paths.is_empty() { + return Err(io::Error::new( + io::ErrorKind::Other, + "Can not find Windows SDK", + )); + } + + println!("{:?}", rc_exe_paths); + let rc_path = rc_exe_paths.pop().unwrap(); + + let rc_exe = if !rc_path.exists() { + if cfg!(target_arch = "x86_64") { + PathBuf::from(rc_path.parent().unwrap()).join(r"bin\x64\rc.exe") + } else { + PathBuf::from(rc_path.parent().unwrap()).join(r"bin\x86\rc.exe") + } + } else { + rc_path + }; + + println!("Selected RC path: '{}'", rc_exe.display()); + Ok(rc_exe) + } + } + } + } + + fn write_resource_file(rc_path: &Path, icon_path: &str) -> io::Result<()> { + let mut f = std::fs::File::create(rc_path)?; + writeln!(f, "{} ICON \"{}\"", 1, icon_path)?; + + Ok(()) + } }