From 076f236bb8bf0ff64f1bfadbb1379f69e8ad32bc Mon Sep 17 00:00:00 2001 From: Scott Hutton Date: Tue, 9 Jan 2024 10:52:41 -0800 Subject: [PATCH] clamav-sys: Fix up Windows build --- clamav-sys/build.rs | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/clamav-sys/build.rs b/clamav-sys/build.rs index 3560260371..c7baa61ef3 100644 --- a/clamav-sys/build.rs +++ b/clamav-sys/build.rs @@ -165,8 +165,11 @@ fn cargo_common() { println!("cargo:rerun-if-changed=wrapper.h"); } -#[cfg(windows)] -pub fn main() { +fn main() -> anyhow::Result<()> { + #[cfg(not(windows))] + let mut include_paths = vec![]; + + #[cfg(windows)] let include_paths = match vcpkg::find_package("clamav") { Ok(pkg) => pkg.include_paths, Err(err) => { @@ -198,20 +201,6 @@ pub fn main() { } }; - cargo_common(); - generate_bindings(&|x: bindgen::Builder| -> bindgen::Builder { - let mut x = x; - for include_path in &include_paths { - x = x.clang_arg("-I").clang_arg(include_path.to_str().unwrap()); - } - x - }); -} - -#[cfg(unix)] -fn main() -> anyhow::Result<()> { - let mut include_paths = vec![]; - let mut output_path_intmod = PathBuf::from(env::var("OUT_DIR")?); output_path_intmod.push("sys.rs"); @@ -228,12 +217,15 @@ fn main() -> anyhow::Result<()> { // This crate is being referenced from an external project. Utilize the // system-installed copy of libclamav (as located using pkg-config). - let libclamav = pkg_config::Config::new() - .atleast_version("0.103") - .probe("libclamav") - .unwrap(); + #[cfg(not(windows))] + { + let libclamav = pkg_config::Config::new() + .atleast_version("0.103") + .probe("libclamav") + .unwrap(); - include_paths.extend_from_slice(&libclamav.include_paths); + include_paths.extend_from_slice(&libclamav.include_paths); + } // Build a vestigial `sys` module, as there will be no access to // internal APIs.