blob: 89c0f6d5aeb706947d8229efcea441af3e8f4b41 (
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
|
use std::path::PathBuf;
fn main() {
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={}/lib", dst.display());
}
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 = 'a'..'z';
for ver in ssl_very_minor_version.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.
"#
})
}
|