-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
79 lines (68 loc) · 2.37 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
67
68
69
70
71
72
73
74
75
76
77
78
79
fn compile() -> String {
let build_type = if Ok("release".to_owned()) == std::env::var("PROFILE") {
"Release"
} else {
"Debug"
};
let mut conf = cmake::Config::new("valhalla");
if cfg!(target_os = "macos") {
conf.cxxflag("-DGEOS_INLINE");
}
let dst = conf
.define("ENABLE_TESTS", "OFF")
.define("ENABLE_BENCHMARKS", "OFF")
.define("ENABLE_HTTP", "OFF")
.define("ENABLE_SERVICES", "OFF")
.define("ENABLE_PYTHON_BINDINGS", "OFF")
.define("CMAKE_BUILD_TYPE", build_type)
.build();
dst.display().to_string()
}
fn generate_bindings(out_dir: String) {
let includes = vec![
"src".to_string(),
"include".to_string(),
format!("{}/include", out_dir),
"valhalla/third_party/date/include".to_string(),
"valhalla/third_party/rapidjson/include".to_string(),
];
let mut b = autocxx_build::Builder::new("src/lib.rs", &includes)
.extra_clang_args(&["-std=c++14"])
.expect_build();
b.opt_level(2)
.cpp(true)
.flag_if_supported("-std=c++14")
.flag_if_supported("/std:c++14")
.file("src/valhalla.cc")
.compile("valhalla-wrapper");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rustc-link-search={}/lib", out_dir);
println!("cargo:rustc-link-lib=valhalla");
//println!("cargo:rustc-link-lib=prime_server");
println!("cargo:rustc-link-lib=protoc");
println!("cargo:rustc-link-lib=protobuf");
println!("cargo:rustc-link-lib=zmq");
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=boost_program_options");
println!("cargo:rustc-link-lib=curl");
println!("cargo:rustc-link-lib=spatialite");
println!("cargo:rustc-link-lib=sqlite3");
println!("cargo:rustc-link-lib=luajit-5.1");
println!("cargo:rustc-link-lib=geos");
println!("cargo:rustc-link-lib=gssapi_krb5");
}
fn compile_protos() {
tonic_build::configure()
.build_client(false)
.build_server(false)
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.format(false)
.compile(&["valhalla/proto/api.proto"], &["valhalla/proto/"])
.expect("compiling protos");
}
fn main() {
let out_dir = compile();
println!("OUT_DIR: {}", out_dir);
generate_bindings(out_dir);
compile_protos();
}