Use native tls as default tls backend, add features to use rustls or openssl instead

This commit is contained in:
bytedream 2023-09-21 13:46:23 +02:00
parent 185b65fc9b
commit 8eda8df3f7
6 changed files with 103 additions and 56 deletions

View file

@ -3,6 +3,29 @@ use clap_complete::shells;
use std::path::{Path, PathBuf};
fn main() -> std::io::Result<()> {
let rustls_tls = cfg!(feature = "rustls-tls");
let native_tls = cfg!(feature = "native-tls");
let openssl_tls = cfg!(any(feature = "openssl-tls", feature = "openssl-tls-static"));
if rustls_tls as u8 + native_tls as u8 + openssl_tls as u8 > 1 {
let active_tls_backend = if openssl_tls {
"openssl"
} else if native_tls {
"native tls"
} else {
"rustls"
};
println!("cargo:warning=Multiple tls backends are activated (through the '*-tls' features). Consider to activate only one as it is not possible to change the backend during runtime. The active backend for this build will be '{}'.", active_tls_backend)
}
if cfg!(feature = "openssl") {
println!("cargo:warning=The 'openssl' feature is deprecated and will be removed in a future version. Use the 'openssl-tls' feature instead.")
}
if cfg!(feature = "openssl-static") {
println!("cargo:warning=The 'openssl-static' feature is deprecated and will be removed in a future version. Use the 'openssl-tls-static' feature instead.")
}
// note that we're using an anti-pattern here / violate the rust conventions. build script are
// not supposed to write outside of 'OUT_DIR'. to have the generated files in the build "root"
// (the same directory where the output binary lives) is much simpler than in 'OUT_DIR' since