From b85992fa076cf64380c1f0a6dada72859a52036a Mon Sep 17 00:00:00 2001 From: "prz@zeta2.ch" Date: Thu, 13 May 2021 10:58:41 +0200 Subject: [PATCH] use the LIBXML2 variable if set directly instead of figuring out packaging --- build.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/build.rs b/build.rs index 21b2ac0bde..973dd132b6 100644 --- a/build.rs +++ b/build.rs @@ -1,19 +1,29 @@ fn main() { - #[cfg(any(target_family="unix", target_os="macos"))] - { - if pkg_config_dep::find() { - return; - } - } + if let Ok(ref s) = std::env::var("LIBXML2") { + // println!("{:?}", std::env::vars()); + // panic!("set libxml2."); + let p = std::path::Path::new(s); + let fname = std::path::Path::new(p.file_name().expect("no file name in LIBXML2 env")); + assert!(p.is_file()); + println!("cargo:rustc-link-lib={}", fname.file_stem().unwrap().to_string_lossy()); + println!("cargo:rustc-link-search={}", p.parent().expect("no library path in LIBXML2 env").to_string_lossy()); + } else { + #[cfg(any(target_family = "unix", target_os = "macos"))] + { + if pkg_config_dep::find() { + return; + } + } - #[cfg(windows)] - { - if vcpkg_dep::find() { - return; - } - } + #[cfg(windows)] + { + if vcpkg_dep::find() { + return; + } + } - panic!("Could not find libxml2.") + panic!("Could not find libxml2.") + } } #[cfg(any(target_family="unix", target_os="macos"))]