From 794636e208aa38a281616c26a75a373fcf9618cd Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 4 Mar 2024 22:19:18 +0800 Subject: [PATCH] use winres in portable --- Cargo.lock | 47 ++-------------------------------------- Cargo.toml | 5 ++--- libs/portable/Cargo.toml | 16 ++++++++++---- libs/portable/build.rs | 23 ++++++++++++++------ res/bump.sh | 2 +- 5 files changed, 33 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3886cfa2b..5cc5163da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,19 +1834,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" -[[package]] -name = "embed-resource" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54cc3e827ee1c3812239a9a41dede7b4d7d5d5464faa32d71bd7cba28ce2cb2" -dependencies = [ - "cc", - "rustc_version", - "toml 0.8.6", - "vswhom", - "winreg 0.51.0", -] - [[package]] name = "encoding_rs" version = "0.8.33" @@ -5512,13 +5499,13 @@ dependencies = [ [[package]] name = "rustdesk-portable-packer" -version = "0.1.0" +version = "1.2.4" dependencies = [ "brotli", "dirs 5.0.1", - "embed-resource", "md5", "winapi 0.3.9", + "winres", ] [[package]] @@ -6923,26 +6910,6 @@ dependencies = [ "log", ] -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "waker-fn" version = "1.1.1" @@ -7706,16 +7673,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937f3df7948156640f46aacef17a70db0de5917bda9c92b0f751f3a955b588fc" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - [[package]] name = "winres" version = "0.1.12" diff --git a/Cargo.toml b/Cargo.toml index 1c959e3d5..782e5b23f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,9 +162,8 @@ members = ["libs/scrap", "libs/hbb_common", "libs/enigo", "libs/clipboard", "lib exclude = ["vdi/host", "examples/custom_plugin"] [package.metadata.winres] -LegalCopyright = "Copyright © 2023 Purslane, Inc." -# this FileDescription overrides package.description -FileDescription = "RustDesk" +LegalCopyright = "Copyright © 2024 Purslane, Inc." +OriginalFilename = "rustdesk.exe" [target.'cfg(target_os="windows")'.build-dependencies] winres = "0.1" diff --git a/libs/portable/Cargo.toml b/libs/portable/Cargo.toml index 6762ce893..307f5716c 100644 --- a/libs/portable/Cargo.toml +++ b/libs/portable/Cargo.toml @@ -1,17 +1,25 @@ [package] name = "rustdesk-portable-packer" -version = "0.1.0" +version = "1.2.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html build = "build.rs" -[build-dependencies] -embed-resource = "2.1" - [dependencies] brotli = "3.4" dirs = "5.0" md5 = "0.7" winapi = { version = "0.3", features = ["winbase"] } + +[package.metadata.winres] +LegalCopyright = "Copyright © 2024 Purslane, Inc." +ProductName = "rustdesk" +#ProductVersion = "" + +[target.'cfg(target_os="windows")'.build-dependencies] +winres = "0.1" +winapi = { version = "0.3", features = [ "winnt", "pdh", "synchapi" ] } + + diff --git a/libs/portable/build.rs b/libs/portable/build.rs index 4f33273f5..be469ab17 100644 --- a/libs/portable/build.rs +++ b/libs/portable/build.rs @@ -1,10 +1,19 @@ -extern crate embed_resource; -use std::fs; - fn main() { - let runner_res_path = "Runner.res"; - match fs::metadata(runner_res_path) { - Ok(_) => println!("cargo:rustc-link-lib=dylib:+verbatim=./libs/portable/Runner.res"), - Err(_) => embed_resource::compile("icon.rc", embed_resource::NONE), + #[cfg(windows)] + { + let mut res = winres::WindowsResource::new(); + res.set_icon("../../res/icon.ico") + .set_language(winapi::um::winnt::MAKELANGID( + winapi::um::winnt::LANG_ENGLISH, + winapi::um::winnt::SUBLANG_ENGLISH_US, + )) + .set_manifest_file("../../res/manifest.xml"); + match res.compile() { + Err(e) => { + write!(std::io::stderr(), "{}", e).unwrap(); + std::process::exit(1); + } + Ok(_) => {} + } } } diff --git a/res/bump.sh b/res/bump.sh index d1142d58c..0fb62a0ac 100644 --- a/res/bump.sh +++ b/res/bump.sh @@ -1,3 +1,3 @@ #! /usr/bin/env bash -sed -i "s/$1/$2/g" res/*spec res/PKGBUILD flutter/pubspec.yaml Cargo.toml .github/workflows/*yml flatpak/*json appimage/*yml +sed -i "s/$1/$2/g" res/*spec res/PKGBUILD flutter/pubspec.yaml Cargo.toml .github/workflows/*yml flatpak/*json appimage/*yml libs/portable/Cargo.toml cargo run # to bump version in cargo lock