From 00498ce6f4b9f36bd83f5b98d35f1d0a11de63fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 22 May 2026 14:45:32 -0400 Subject: [PATCH 1/2] fix(jetsocat): embed Windows icon and version metadata --- Cargo.lock | 1 + jetsocat/Cargo.toml | 4 ++ jetsocat/build.rs | 91 +++++++++++++++++++++++++++++++++++++++++++ jetsocat/resources.rc | 1 + 4 files changed, 97 insertions(+) create mode 100644 jetsocat/build.rs create mode 100644 jetsocat/resources.rc diff --git a/Cargo.lock b/Cargo.lock index 427810a10..ea1b698f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3601,6 +3601,7 @@ dependencies = [ "anyhow", "base64 0.22.1", "dirs-next", + "embed-resource", "futures-util", "humantime", "jet-proto", diff --git a/jetsocat/Cargo.toml b/jetsocat/Cargo.toml index 230013fe6..af6eea937 100644 --- a/jetsocat/Cargo.toml +++ b/jetsocat/Cargo.toml @@ -4,6 +4,7 @@ version.workspace = true authors = ["Devolutions Inc. "] edition = "2024" description = "(Web)Socket toolkit for jet protocol related operations" +build = "build.rs" publish = false [lints] @@ -81,3 +82,6 @@ features = [ "Win32_Globalization", ] +[target.'cfg(windows)'.build-dependencies] +embed-resource = "3.0" + diff --git a/jetsocat/build.rs b/jetsocat/build.rs new file mode 100644 index 000000000..def6a6d05 --- /dev/null +++ b/jetsocat/build.rs @@ -0,0 +1,91 @@ +fn main() { + #[cfg(target_os = "windows")] + win::embed_resources(); +} + +#[cfg(target_os = "windows")] +mod win { + use std::{env, fs}; + + pub(super) fn embed_resources() { + let out_dir = env::var("OUT_DIR").expect("failed to get OUT_DIR"); + let version_rc_file = format!("{out_dir}/version.rc"); + let version_rc_data = generate_version_rc(); + fs::write(&version_rc_file, version_rc_data).expect("failed to write version.rc"); + + println!("cargo:rerun-if-changed=resources.rc"); + println!("cargo:rerun-if-changed=../package/WindowsManaged/Resources/DevolutionsGateway.ico"); + + embed_resource::compile(&version_rc_file, embed_resource::NONE) + .manifest_required() + .expect("failed to compile version.rc"); + embed_resource::compile("resources.rc", embed_resource::NONE) + .manifest_required() + .expect("failed to embed resources.rc"); + } + + fn generate_version_rc() -> String { + let output_name = "jetsocat"; + let filename = format!("{output_name}.exe"); + let company_name = "Devolutions Inc."; + let legal_copyright = format!("Copyright 2020-2026 {company_name}"); + + let mut version_number = env::var("CARGO_PKG_VERSION").expect("failed to get CARGO_PKG_VERSION"); + version_number.push_str(".0"); + let version_commas = version_number.replace('.', ","); + let file_description = "jetsocat"; + let file_version = version_number.clone(); + let internal_name = filename.clone(); + let original_filename = filename; + let product_name = "jetsocat"; + let product_version = version_number; + let vs_file_version = version_commas.clone(); + let vs_product_version = version_commas; + + format!( + r#"#include +VS_VERSION_INFO VERSIONINFO + FILEVERSION {vs_file_version} + PRODUCTVERSION {vs_product_version} + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "{company_name}" + VALUE "FileDescription", "{file_description}" + VALUE "FileVersion", "{file_version}" + VALUE "InternalName", "{internal_name}" + VALUE "LegalCopyright", "{legal_copyright}" + VALUE "OriginalFilename", "{original_filename}" + VALUE "ProductName", "{product_name}" + VALUE "ProductVersion", "{product_version}" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END"#, + vs_file_version = vs_file_version, + vs_product_version = vs_product_version, + company_name = company_name, + file_description = file_description, + file_version = file_version, + internal_name = internal_name, + legal_copyright = legal_copyright, + original_filename = original_filename, + product_name = product_name, + product_version = product_version + ) + } +} \ No newline at end of file diff --git a/jetsocat/resources.rc b/jetsocat/resources.rc new file mode 100644 index 000000000..64f226da8 --- /dev/null +++ b/jetsocat/resources.rc @@ -0,0 +1 @@ +101 ICON "../package/WindowsManaged/Resources/DevolutionsGateway.ico" \ No newline at end of file From 415971d708b9b633236f67634b1f26dbe4f62f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 22 May 2026 21:32:02 -0400 Subject: [PATCH 2/2] style: format jetsocat build script --- jetsocat/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetsocat/build.rs b/jetsocat/build.rs index def6a6d05..f31f15ae7 100644 --- a/jetsocat/build.rs +++ b/jetsocat/build.rs @@ -88,4 +88,4 @@ END"#, product_version = product_version ) } -} \ No newline at end of file +}