58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
use anyhow::Result;
|
|
use cfg_if::cfg_if;
|
|
use std::env;
|
|
|
|
fn main() -> Result<()> {
|
|
println!("cargo:rerun-if-env-changed=FIDO2_LIB_DIR");
|
|
println!("cargo:rerun-if-env-changed=FIDO2_USE_PKG_CONFIG");
|
|
|
|
if let Ok(dir) = env::var("FIDO2_LIB_DIR") {
|
|
println!("cargo:rustc-link-search={}", dir);
|
|
println!("cargo:rustc-link-lib=static=fido2");
|
|
|
|
if cfg!(windows) {
|
|
println!("cargo:rustc-link-lib=hid");
|
|
println!("cargo:rustc-link-lib=user32");
|
|
println!("cargo:rustc-link-lib=setupapi");
|
|
println!("cargo:rustc-link-lib=crypt32");
|
|
}
|
|
|
|
cfg_if! {
|
|
if #[cfg(all(windows, target_env = "msvc"))] {
|
|
// link to pre-build cbor,zlib,crypto
|
|
println!("cargo:rustc-link-lib=cbor");
|
|
println!("cargo:rustc-link-lib=zlib1");
|
|
println!("cargo:rustc-link-lib=crypto-49");
|
|
} else {
|
|
println!("cargo:rustc-link-lib=cbor");
|
|
println!("cargo:rustc-link-lib=z");
|
|
println!("cargo:rustc-link-lib=crypto");
|
|
}
|
|
}
|
|
|
|
return Ok(());
|
|
}
|
|
|
|
find_pkg()
|
|
|
|
}
|
|
|
|
#[cfg(not(target_env = "msvc"))]
|
|
fn find_pkg() -> Result<()> {
|
|
let _lib = pkg_config::probe_library("libfido2")?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(all(windows, target_env = "msvc"))]
|
|
fn find_pkg() -> Result<()> {
|
|
let _lib = vcpkg::find_package("libfido2")?;
|
|
|
|
println!("cargo:rustc-link-lib=hid");
|
|
println!("cargo:rustc-link-lib=user32");
|
|
println!("cargo:rustc-link-lib=setupapi");
|
|
println!("cargo:rustc-link-lib=crypt32");
|
|
|
|
Ok(())
|
|
}
|