extern crate cc;
fn main() {
let api_version;
#[cfg(feature = "fdb-7_1")]
{
api_version = String::from("710");
}
#[cfg(feature = "fdb-7_3")]
{
api_version = String::from("730");
}
#[cfg(feature = "fdb-7_3")]
{
#[cfg(feature = "fdb-docker")]
build_with_clang(&api_version);
#[cfg(not(feature = "fdb-docker"))]
{
display_build_warnings();
crate::build_with_gcc(&api_version);
}
}
#[cfg(feature = "fdb-7_1")]
{
#[cfg(not(feature = "fdb-docker"))]
display_build_warnings();
build_with_gcc(&api_version);
}
}
fn display_build_warnings() {
println!("cargo:warning=---------------------");
println!("cargo:warning=------ Warning ------");
println!("cargo:warning=---------------------");
println!("cargo:warning=Building the crate without the `fdb-docker` feature will be valid from Rust's perspective but not from C++ and FoundationDB");
println!("cargo:warning=Please follow the instructions in the associated README");
}
fn build_with_gcc(api_version: &str) {
cc::Build::new()
.cpp(true)
.std("c++14")
.define("FDB_API_VERSION", api_version)
.file("src/FDBWrapper.cpp")
.file("src/FDBWorkload.cpp")
.compile("libctx.a");
}
fn build_with_clang(api_version: &str) {
cc::Build::new()
.compiler("clang")
.cpp_set_stdlib("c++")
.cpp(true)
.std("c++14")
.define("FDB_API_VERSION", api_version)
.file("src/FDBWrapper.cpp")
.file("src/FDBWorkload.cpp")
.compile("libctx.a");
}