-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
66 lines (64 loc) · 2.61 KB
/
build.rs
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
55
56
57
58
59
60
61
62
63
64
65
66
fn main() {
let folly_include_dir =
std::env::var("FOLLY_INCLUDE_DIR").expect("Can't read FOLLY_INCLUDE_DIR env var");
let mut builder = cxx_build::bridge("src/bridge.rs");
builder
.file("blobstore/blobstore.cc")
.std("c++20")
.include("./")
.include("./cxx-async/cxx-async/include")
.flag("-DFMT_HEADER_ONLY")
.flag("-DUSE_FOLLY_LOGGING")
.flag("-Wno-nullability-completeness")
.flag("-Wno-deprecated-builtins")
.include(&folly_include_dir);
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if std::env::var_os("CARGO_CFG_UNIX").is_some() {
builder
.flag("-D_GNU_SOURCE=1")
.flag("-finput-charset=UTF-8")
.flag("-fsigned-char")
.flag("-faligned-new");
if let Some(target_os) = std::env::var_os("CARGO_CFG_TARGET_OS") {
if target_os == "linux" {
builder
.flag("-DHAVE_LINUX_TIME_TYPES_H")
.include(&format!("{}/libevent-1.4.14b", folly_include_dir))
.include(&format!(
"{}/libevent-1.4.14b/{}-linux",
folly_include_dir, target_arch
));
} else if target_os == "macos" && target_arch == "aarch64" {
builder
.include(&format!("{}/libevent-2.1.12", folly_include_dir))
.include(&format!(
"{}/libevent-2.1.12/arm64-darwin",
folly_include_dir
));
}
}
} else if std::env::var_os("CARGO_CFG_WINDOWS").is_some() {
builder
.flag("-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE")
.flag("-DFOLLY_INTERNAL_NONSTDC_NAMES")
.flag("-DFOLLY_MINIGLOG_USING_SHARED_LIBRARY")
.flag("-DBOOST_ALL_NO_LIB")
.flag("-Wno-unsafe-buffer-usage")
.flag("-Wno-dollar-in-identifier-extension")
.flag("/EHs")
.flag("/GF")
.flag("/Zc:rvalueCast")
.flag("/Zc:strictStrings")
.flag("/Zc:threadSafeInit")
.flag("/permissive-")
.include(&format!("{}/libevent-2.1.12", folly_include_dir))
.include(&format!(
"{}/libevent-2.1.12/{}-windows",
folly_include_dir, target_arch
));
}
builder.compile("blobstore");
println!("cargo:rerun-if-changed=src/bridge.rs");
println!("cargo:rerun-if-changed=blobstore/blobstore.cc");
println!("cargo:rerun-if-changed=blobstore/blobstore.h");
}