Skip to content

Commit

Permalink
clamav-sys: Fix up Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
shutton committed Jan 9, 2024
1 parent a1fa8e4 commit 076f236
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions clamav-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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");

Expand All @@ -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.
Expand Down

0 comments on commit 076f236

Please sign in to comment.