From 071796acd3d9b0605bfbb7e24bc4c6c6d5ddde77 Mon Sep 17 00:00:00 2001 From: Guilherme Cardoso Date: Mon, 21 Sep 2026 23:26:30 +0100 Subject: [PATCH] build: generate src/version.rs without hbb_common build.rs called hbb_common::gen_version(), which made hbb_common a build dependency, so cargo compiled the whole crate for the build host, including libsodium-sys. When cross compiling with pkg-config pointed at the target sysroot, the host build script then links the target libsodium and fails at link time. That is what happens on every non-x86_64 OpenWrt target. Write src/version.rs from CARGO_PKG_VERSION with the standard library instead. BUILD_DATE is kept as an empty constant: nothing in hbbs or hbbr reads it, and a constant value makes the build reproducible. Signed-off-by: Guilherme Cardoso --- Cargo.toml | 3 --- build.rs | 13 ++++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43963d125..c5225c354 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,9 +60,6 @@ reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocki [target.'cfg(not(any(target_os = "macos", target_os = "windows")))'.dependencies] reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocking", "socks", "json", "rustls-tls", "rustls-tls-native-roots", "gzip"], default-features=false } -[build-dependencies] -hbb_common = { path = "libs/hbb_common" } - [workspace] members = ["libs/hbb_common"] exclude = ["ui"] diff --git a/build.rs b/build.rs index 9f8c85547..1dbb1c0b6 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,14 @@ +use std::{env, fs}; + fn main() { - hbb_common::gen_version(); + println!("cargo:rerun-if-changed=Cargo.toml"); + let version = env::var("CARGO_PKG_VERSION").unwrap(); + fs::write( + "./src/version.rs", + format!( + "pub const VERSION: &str = \"{version}\";\n\ + #[allow(dead_code)]\npub const BUILD_DATE: &str = \"\";\n" + ), + ) + .unwrap(); }