1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#[cfg(feature = "vendored")]
fn emit_dylibs() -> Vec<&'static str> {
// Windows doesn't need to dynamically link the C++ runtime
// but we do need to link to DLLs with needed functionality:
if cfg!(target_os = "windows") {
return vec!["user32", "crypt32"];
}
// On Linux we use libstdc++
if cfg!(any(target_os = "linux")) {
return vec!["stdc++"];
}
// For all other platforms, link to libc++ from LLVM/Clang
vec!["c++"]
}
fn botan_lib_major_version() -> i32 {
if cfg!(any(feature = "vendored", feature = "botan3")) {
3
} else {
2
}
}
fn botan_library_name() -> String {
let major_version = botan_lib_major_version();
if cfg!(target_os = "windows") && major_version == 2 {
// For some unknown reason, Botan 2.x does not include
// the major version in the name of the Windows library
"botan".to_string()
} else {
format!("botan-{major_version}")
}
}
fn main() {
#[cfg(feature = "vendored")]
{
let (lib_dir, _) = botan_src::build();
println!("cargo:vendored=1");
println!("cargo:rustc-link-search=native={}", &lib_dir);
println!("cargo:rustc-link-lib=static={}", botan_library_name(),);
for dylib in emit_dylibs() {
println!("cargo:rustc-flags=-l dylib={}", dylib);
}
}
#[cfg(not(feature = "vendored"))]
{
println!("cargo:rustc-link-lib={}", botan_library_name());
}
}
|