-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
33 lines (25 loc) · 886 Bytes
/
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
extern crate pkg_config;
extern crate gcc;
use std::env;
fn main() {
let mut gcc_config = gcc::Config::new();
gcc_config.cpp(true);
let lib_dir = env::var("PROTOBUF_LIB_DIR").ok();
let include_dir = env::var("PROTOBUF_INCLUDE_DIR").ok();
if let Some(ref lib_dir) = lib_dir {
println!("cargo:rustc-link-search=native={}", lib_dir);
}
if let Some(ref include_dir) = include_dir {
println!("cargo:include={}", include_dir);
gcc_config.include(include_dir);
}
if lib_dir.is_none() && include_dir.is_none() {
let protobuf_lib = pkg_config::find_library("protobuf").unwrap();
for path in protobuf_lib.include_paths {
gcc_config.include(path);
}
}
println!("cargo:rustc-flags=-l protoc");
gcc_config.file("src/glue.cpp")
.compile("librust-protobuf-build-glue.a");
}