From 2276942bb04577028134d533b1c875066133b52b Mon Sep 17 00:00:00 2001 From: Chiichen Date: Sat, 30 Nov 2024 18:47:11 +0800 Subject: [PATCH] fix: compile error on Windows because of macro WIN32 --- libvnc-sys/Cargo.toml | 2 +- libvnc-sys/build.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libvnc-sys/Cargo.toml b/libvnc-sys/Cargo.toml index fb85207..b857b9a 100644 --- a/libvnc-sys/Cargo.toml +++ b/libvnc-sys/Cargo.toml @@ -18,7 +18,7 @@ bindgen = "0.70.0" cc = "1.0.95" pkg-config = "0.3.30" cmake = "0.1.52" -which = "7.0.0" +# which = "7.0.0" [features] default = [] diff --git a/libvnc-sys/build.rs b/libvnc-sys/build.rs index 7b39728..c5d3a02 100644 --- a/libvnc-sys/build.rs +++ b/libvnc-sys/build.rs @@ -60,11 +60,19 @@ fn bindgen_vncserver() { ); } } else if target_os == "windows" { - config.generator("Ninja"); - config.no_default_flags(true); + // Is it necessary? + // config.define( + // "CMAKE_TOOLCHAIN_FILE", + // which::which("vcpkg") + // .expect("Install vcpkg and make sure it can be found in current environment") + // .parent() + // .unwrap() + // .join("scripts/buildsystems/vcpkg.cmake"), + // ); config.define("WITH_OPENSSL", "OFF"); config.define("WITH_GNUTLS", "OFF"); config.define("WITH_GCRYPT", "OFF"); + config.cflag("-DWIN32"); //TODO I think it's a bug in libvncserver. It's expected to use _WIN32 macro to determine whether it's on Windows platform. However, it uses WIN32 instead.@see https://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c } else if target_os == "android" { panic!("unsupported build target {}", target_os) } @@ -83,7 +91,7 @@ fn bindgen_vncserver() { .clang_args([ format!("-I{}/{}", dst.display(), "include"), #[cfg(target_os = "windows")] - r#"-DWIN32"#.to_string(), //TODO I think it's a bug in libvncserver. It's expected to use _WIN32 macro to determine whether it's on Windows platform. However, it uses WIN32 instead.@see https://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c + r#"-DWIN32"#.to_string(), // As Above ]) .generate() .expect("unable to generate rfb bindings");