blob: 619ad4c5642b4ff0c72969031ae7b3d388a85b24 (
plain) (
blame)
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
|
use std::path::PathBuf;
fn main() {
//let crate_root: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
/*let tdlib_path: PathBuf = {
env::var("TDLIB_LIBRARY_PATH")
.map_or_else(|_err| crate_root.join("td/build"), PathBuf::from)
};*/
if cfg!(not(feature = "tdlib-provided")) {
build_tdlib();
}
}
fn build_tdlib() {
let mut config = cmake::Config::new("td");
config.very_verbose(true);
if cfg!(not(feature = "openssl-provided")) {
let openssl = guess_openssl_location();
config.define("OPENSSL_ROOT_DIR", openssl);
}
let dst = config.build();
println!("cargo:rustc-link-search={}", dst.display()); // tdlib_path.to_string_lossy());
}
fn guess_openssl_location() -> PathBuf {
let mut openssl: Option<PathBuf> = std::env::var("OPENSSL_ROOT_DIR")
.map(std::convert::Into::into)
.ok();
if cfg!(target_os = "macos") && openssl.is_none() {
let ssl_very_minor_version = "abcdefghi";
for ver in ssl_very_minor_version.chars().rev() {
let maybe_path = PathBuf::from(format!("/usr/local/Cellar/openssl@1.1/1.1.1{}", ver));
if maybe_path.is_dir() {
openssl = Some(maybe_path);
break;
}
}
}
openssl.expect(indoc::indoc! {r#"
Could not find openssl.
You must either use feature \"openssl-provided\"
or provide "OPENSSL_ROOT_DIR" env variable, so tdlib-sys can build
TDLib from sources.
"#
})
}
|